Coder Social home page Coder Social logo

chsvgaplayer-ios's Introduction

CHSVGAPlayer-iOS

CI Status Version License Platform

缘由

SVGAPlayer2.0缓存策略默认为NSURLCache+NSCache,缓存优先级上,NSURLCache > NSCache,这样会导致一些问题:

  • NSURLCache的HTTP配置选项需符合要求:如果服务器返回的头部信息包含 cache-control / etag / expired 这些键值,这个请求会被合理地缓存到本地点击,如不符合要求,则会重复进行下载,导致应用带宽被频繁占用。
  • NSCache只支持内存缓存且不支持手动清理缓存,无法适应需手动释放的业务场景。

解决方案

针对SVGA存在的问题,使用YYCache替代NSURLCache+NSCache,通过YYCache本身的二级缓存机制优化SVGAPlayer2.0缓存策略。

使用方案

  • 移除SVGAPlayer组件

  • 添加CHSVGAPlayer-iOS组件

pod 'CHSVGAPlayer-iOS'
  • 使用的地方导入
#import "SVGAVideoEntity+CHSVGA.h"

// 支持内存缓存, 默认为YES
- (SVGAParser *)parser {
    if (_parser == nil) {
        _parser = [[SVGAParser alloc] init];
        _parser.enabledMemoryCache = YES;
    }
    return _parser;
}

// 清除内存缓存
[SVGAVideoEntity chsvga_clearMemoryCache];

// 设置内存缓存最大值, 默认为10M
[SVGAVideoEntity chsvga_setupMemoryCacheCostLimit:10 * 1024]

Author

ColinHwang, [email protected]

License

CHSVGAPlayer-iOS is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.