Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


High performance cache framework for iOS.

Subscribe to updates I use YYCache

Statistics on YYCache

Number of watchers on Github 1691
Number of open issues 50
Average time to close an issue 6 days
Main language Objective-C
Average time to merge a PR about 14 hours
Open pull requests 1+
Closed pull requests 2+
Last commit about 2 years ago
Repo Created almost 4 years ago
Repo Last Updated over 1 year ago
Size 4.73 MB
Organization / Authoribireme
Latest Release1.0.3
Page Updated
Do you use YYCache? Leave a review!
View open issues (50)
View YYCache activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating YYCache for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


License MIT  Carthage compatible  CocoaPods  CocoaPods  Support  Build Status

High performance cache framework for iOS.
(It's a component of YYKit)


Memory cache benchmark result

Disk benchmark result

You may download and compile the latest version of sqlite and ignore the libsqlite3.dylib in iOS system to get higher performance.

See Benchmark/CacheBenchmark.xcodeproj for more benchmark case.


  • LRU: Objects can be evicted with least-recently-used algorithm.
  • Limitation: Cache limitation can be controlled with count, cost, age and free space.
  • Compatibility: The API is similar to NSCache, all methods are thread-safe.
  • Memory Cache
    • Release Control: Objects can be released synchronously/asynchronously on main thread or background thread.
    • Automatically Clear: It can be configured to automatically evict objects when receive memory warning or app enter background.
  • Disk Cache
    • Customization: It supports custom archive and unarchive method to store object which does not adopt NSCoding.
    • Storage Type Control: It can automatically decide the storage type (sqlite / file) for each object to get better performance.



  1. Add pod 'YYCache' to your Podfile.
  2. Run pod install or pod update.
  3. Import <YYCache/YYCache.h>.


  1. Add github "ibireme/YYCache" to your Cartfile.
  2. Run carthage update --platform ios and add the framework to your project.
  3. Import <YYCache/YYCache.h>.


  1. Download all the files in the YYCache subdirectory.
  2. Add the source files to your Xcode project.
  3. Link with required frameworks:
    • UIKit
    • CoreFoundation
    • QuartzCore
    • sqlite3
  4. Import YYCache.h.


Full API documentation is available on CocoaDocs.
You can also install documentation locally using appledoc.


This library requires iOS 6.0+ and Xcode 8.0+.


YYCache is provided under the MIT license. See LICENSE file for details.

============== iOS
( YYKit )


iPhone 6 (): Memory cache benchmark result

iPhone 6 (): Disk benchmark result

SQLite SQLite iOS libsqlite3.dylib



  • LRU: LRU (least-recently-used)
  • ****:
  • ****: API NSCache ,
  • ****
    • ****: (release)
    • ****: App
  • ****
    • ****: NSCoding
    • ****: (SQLite/)



  1. Podfile pod 'YYCache'
  2. pod install pod update
  3. <YYCache/YYCache.h>


  1. Cartfile github "ibireme/YYCache"
  2. carthage update --platform ios framework
  3. <YYCache/YYCache.h>
  1. YYCache
  2. YYCache ()
  3. frameworks:
    • UIKit
    • CoreFoundation
    • QuartzCore
    • sqlite3
  4. YYCache.h

============== CocoaDocs API appledoc

============== iOS 6.0 Xcode 8.0

============== YYCache MIT LICENSE

============== YYCache

YYCache open issues Ask a question     (View All Issues)
  • almost 3 years TMCache 是你写的吗?
  • almost 3 years YYMemoryCache的问题
  • almost 3 years 关于MemoryCache的疑惑,望解惑
  • almost 3 years 请问,我使用YYCache类存储的时候,怎么设置diskCache的 缓存大小?
  • almost 3 years 拜读代码过程有些疑问请指教
  • almost 3 years 怎么一次取出所有objects
  • almost 3 years YYKVStorage 异常crash
  • about 3 years 缓存同时执行读取操作失败的问题
  • about 3 years 为什么有时候读取出来的cache为空?
  • about 3 years YYCache保存模型后再取出来的问题
  • about 3 years OSSpinLock 有一个比较严重的问题,是不是考虑把框架中的这个自旋锁用dispatch_semaphore来进行替换?
  • about 3 years 提一个小小的疑问
  • about 3 years YYMemoryCache
  • about 3 years 关于DiskCache跟MemoryCache的问题
  • about 3 years 关于countLimit与costLimit
  • about 3 years 拜读了下YYCache.有些疑惑.
  • about 3 years 推荐到 SQLite 官网下载和编译最新的 SQLite,以替换 iOS 自带的 libsqlite3.dylib,以获得最高 1.5~3 倍的性能提升。
  • over 3 years 用setObjeck:forKey: 多次存一个类型的对象,怎么可以一次获取所有的allValues??
  • over 3 years 能单独设置每个缓存的存活时间吗?
  • over 3 years separate YYKVStorage to another project
  • almost 4 years Support for cached object timeout
YYCache open pull requests (View All Pulls)
  • 增加Expiration扩展
YYCache list of languages used
YYCache latest release notes
1.0.3 Enhance stability
  • Typo fix
  • Do more check and retry on sqlite error
1.0.2 Bug fixes
  • Fix bug in LRU policy for storage sql when evicts objects
1.0.1 Bug fixes
  • Destroy pthread_mutex on dealloc #30
  • Remove YYDispatchQueuePool due to dynamic library compile error.
Other projects in Objective-C