jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Available as stand-alone cache w/o Angular? #189

Closed marnusw closed 9 years ago

marnusw commented 9 years ago

This looks like an excellent cache implementation which I wouldn't mind using in a non-angular application. It would seem the angular- part is just a thin wrapper. Is it available for use as a stand-alone cache in another repo, or are there plans to expose the cache separately here with the angular wrapper being optional?

I'm looking for decent client side cache with the expiration features you have here and built in local/sessionStorage support, but beyond that as little bloat as possible.

jmdobry commented 9 years ago

I don't have the non-angular part available as a separate lib, and I hadn't had any plans to, until perhaps right now. I'll take a look at extracting the non-angular code.

marnusw commented 9 years ago

Sounds great! It's not an immediate need yet, but if it will help I can also pitch in over time.

I did notice that your implementation uses some of the Angular helper methods. One thought I had is that one might create a utilities object with the necessary interface, built from Angular helpers when using the Angular version of the cache, and a second, perhaps using Lodash methods if they'd suit, which can be imported when using the cache stand-alone. That might keep a Browserify bundle as lean as possible in both cases.

jmdobry commented 9 years ago

@marnusw What do you think? https://github.com/jmdobry/CacheFactory

marnusw commented 9 years ago

Goodness you're quick! :smile: Thanks, this looks perfect! Once I start using it over the next week or two I'll continue the discussion there if necessary.

I plan to implement a plugin around this for Fluxible. I'll let you know when it's done. Perhaps we can create an index of wrappers around CacheFactory which can grow over time as devs using other frameworks start pitching in.

jmdobry commented 9 years ago

Perhaps. Most of my efforts on data management these days actually center around js-data.

marnusw commented 9 years ago

I figured as much, but I don't think there is a parallel for this cache there, is there? That looks to be a full data management solution? (I'm guessing with cache baked in, but not as a separate component.)