jmdobry / CacheFactory

CacheFactory is a very simple and useful synchronous key-value store for the browser.
http://www.pseudobry.com/CacheFactory
MIT License
30 stars 18 forks source link

Allow async implementation of cache interface #6

Closed jrencz closed 8 years ago

jrencz commented 8 years ago

I tried to connect angular-cache with ocombe/angular-localForage (in general - CacheFactory and mozilla/localForage) but it turns out that async storge implementation is not supported by CacheFactory. For example index.js#L417-L420:

$$storage().removeItem(this.$$prefix + '.data.' + key);
var keysJson = $$storage().getItem(this.$$prefix + '.keys');
var keys = keysJson ? utils.fromJson(keysJson) : [];
var index = keys.indexOf(key);

this clearly does not allow removeItem and getItem to return promises.

@jmdobry are you interested in implementing async storage in CacheFactory? Do you see any obvious cons for this idea?

jmdobry commented 8 years ago

See https://github.com/jmdobry/angular-cache/pull/146#issuecomment-72510034 and https://github.com/jmdobry/angular-cache/issues/108#issuecomment-45746483

I recommend js-data & js-data-localforage instead.

jrencz commented 8 years ago

Ok