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

Performance issue #88

Closed nicolasca closed 10 years ago

nicolasca commented 10 years ago

I have a performance issue with angular-cache. I put around 50-60 in localstorage with a name like "blockReport_518_1_0". Then when my service is initialized, I found that it can take 1min. I made the following test:

    console.log("pre");
    var blockReportCache = $angularCacheFactory( 'blockReportCache', {
        storageMode: 'localStorage',
        maxAge: 600000 
    } );
   console.log("post");

It appears that it take 1 min between the two logs.

Am I missing some options, or is it an issue?

jmdobry commented 10 years ago

There is an option called verifyIntegrity that defaults to true. With this option enabled, angular-cache attempts to verify that the contents of a given cache are correctly synchronized with what's in localStorage on every operation. This incurs a performance a performance penalty for the benefit of data integrity. Try disabling this option for a performance improvement.

More reading:

http://jmdobry.github.io/angular-cache/configuration.html#verifyintegrity

findesk commented 10 years ago

@jmdobry ... fyi...

small update to docs ... they indicate verifyIntegrity defaults to false:

http://jmdobry.github.io/angular-cache/configuration.html#verifyintegrity

But in 2.3.0 verifyIntegrity defaults to true:

https://github.com/jmdobry/angular-cache/blob/2.3.0/src/angular-cache.js#L218

jmdobry commented 10 years ago

@findesk Good catch, the docs have been updated.

jmdobry commented 10 years ago

Performance will be improved in 3.0.0 #95

nicolasca commented 10 years ago

Thanks :)