【问题标题】:How i use Angular DSCacheFactory in Ionic Application我如何在 Ionic 应用程序中使用 Angular DSCacheFactory
【发布时间】:2015-12-24 05:26:42
【问题描述】:

我需要在我的 Ionic/Cordova 应用程序中使用 DSCacheFactory。但我不知道如何使用这个。我对DSCacheFactory也不太了解,我觉得和网络缓存一样。

请帮我找出解决办法

【问题讨论】:

    标签: javascript angularjs ionic-framework ionic browser-cache


    【解决方案1】:

    大多数离子应用程序使用 - Angular Cache。这确实是一个很棒的库,其中包含我们需要的大部分功能。它使用简单,用途广泛。

    只要npm install --save angular-cache

    或者如果您使用的是凉亭bower install --save angular-cache

    API 非常简洁直观。

    存储数据-

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

    检索存储的数据-

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

    获取有关缓存中项目的信息-

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

    获取有关缓存本身的信息-

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

    物品可以很容易地移除,我们可以在完成后销毁我们的缓存-

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

    这些是一些最需要或最需要的功能/操作。它有很好的支持并且非常稳定。感谢jmdobry 提供了如此优雅的库。

    这里有一些参考链接,官方论坛的 ionic 人建议使用这个库-

    希望对您有所帮助 :) 编码愉快!

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-22
    • 2017-09-03
    • 1970-01-01
    • 2017-09-01
    • 2017-06-01
    • 2017-06-29
    • 2016-11-04
    • 1970-01-01
    相关资源
    最近更新 更多