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

Individual Item level cache maxAge is not overriding the maxAge of the whole cache #194

Closed sriramjothimani closed 9 years ago

sriramjothimani commented 9 years ago

Hi,

The maxAge property of individual item stored in a cache is not overriding the maxAge of the whole cache. Even though we set specific maxAge for the individual items it tends to set the maxAge of the cache.

Below is the service we have created.

appCache.service('appCacheSrc', function (CacheFactory) {

var frontendCache;

if(!CacheFactory.get('frontend')){
    frontendCache = CacheFactory('frontend', {
         maxAge: 15 * 60 * 1000 
        ,cacheFlushInterval: 30 * 60 * 1000 
        ,deleteOnExpire: 'aggressive' 
        ,storageMode: 'localStorage' 
    });    

    frontendCache.put('/profiles/34', {
        name: 'John',
        skills: ['programming', 'piano'],
        },{maxAge: 60 * 1000});

}
console.log(frontendCache.info('/profiles/34'));
return frontendCache;

});

Please let me know if am doing something wrong.

Thanks, Sriram

jmdobry commented 9 years ago

You can't set maxAge for individual items On Aug 19, 2015 8:40 AM, "sriramjothimani" notifications@github.com wrote:

Hi,

The maxAge property of individual item stored in a cache is not overriding the maxAge of the whole cache. Even though we set specific maxAge for the individual items it tends to set the maxAge of the cache.

Below is the service we have created.

appCache.service('appCacheSrc', function (CacheFactory) {

var frontendCache;

if(!CacheFactory.get('frontend')){ frontendCache = CacheFactory('frontend', { maxAge: 15 * 60 * 1000 ,cacheFlushInterval: 30 * 60 * 1000 ,deleteOnExpire: 'aggressive' ,storageMode: 'localStorage' });

frontendCache.put('/profiles/34', {
    name: 'John',
    skills: ['programming', 'piano'],
    },{maxAge: 60 * 1000});

} console.log(frontendCache.info('/profiles/34')); return frontendCache;

});

Please let me know if am doing something wrong.

Thanks, Sriram

— Reply to this email directly or view it on GitHub https://github.com/jmdobry/angular-cache/issues/194.

sriramjothimani commented 9 years ago

Ok so I have to create a separate cache if I need to have a different maxAge ?

jmdobry commented 9 years ago

Yes On Aug 19, 2015 8:53 AM, "sriramjothimani" notifications@github.com wrote:

Ok so I have to create a separate cache if I need to have a different maxAge ?

— Reply to this email directly or view it on GitHub https://github.com/jmdobry/angular-cache/issues/194#issuecomment-132626747 .