Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How i use Angular DSCacheFactory in Ionic Application

I need to use DSCacheFactory in my Ionic/Cordova application. But I don't know how to use this. I also don't know much about DSCacheFactory,I think it same like web cache.

Please help me to found out solution

like image 454
SuReSh Avatar asked Dec 24 '15 05:12

SuReSh


1 Answers

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

Just do npm install --save angular-cache

or if you are using bower bower install --save angular-cache

The API's are very clean and intuitive.

To store the data-

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

To retrieve the stored 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.

Items can be removed easily, and we can destroy our cache when we're done with it-

profileCache.remove('/profiles/34');

profileCache.get('/profiles/34'); // undefined

profileCache.destroy();

CacheFactory.get('profileCache'); // undefined

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

Here are some reference links where in official forum of ionic people have suggested to use this library-

  • forum.ionicframework.com

  • Q about angular cache

  • Q about Cache Factory

Hope it helps :) Happy coding!

like image 67
bozzmob Avatar answered Nov 01 '22 11:11

bozzmob