How do I use Angular DSCacheFactory in an ionic application

I need to use DSCacheFactory in my Ionic / Cordova application. But I do not know how to use it. I also know little about DSCacheFactory , I think it is the same as in the web cache.

Please help me find a solution

+6
source share
1 answer

Most of the use of the ionic application is Angular Cache . This is a really great library with most of the features we need in it already. It is easy to use and serves purpose.

Just do npm install --save angular-cache

or if you use the bower bower install --save angular-cache

The API is very clean and intuitive.

To save data -

 profileCache.put('/profiles/34', { name: 'John', skills: ['programming', 'piano'] }); 

To get saved data -

 var profile = profileCache.get('/profiles/34'); profile.name; // 'John' 

Get information about items in the cache

 var info = profileCache.info('/profiles/34'); info.isExpired; // false // etc. 

Get information about the cache itself -

 var info = profileCache.info(); info.size; // 2 info.maxAge; // 3600000 info.deleteOnExpire; // 'aggressive' // etc. 

Elements can be easily removed, and we can destroy our cache when we are done with it -

 profileCache.remove('/profiles/34'); profileCache.get('/profiles/34'); // undefined profileCache.destroy(); CacheFactory.get('profileCache'); // undefined 

These are some of the most needed or necessary functions / operations. It has great support and is pretty stable. Thanks to jmdobry for such an elegant library.

Here are some links where you can use this library on the official forum of ionic people -

Hope this helps :) Happy coding!

+10
source

All Articles