DEV Community

hlc0000
hlc0000

Posted on • Edited on • Originally published at github.com

Thread safe IOS universal cache SwiftlyCache

In IOS development, cache is more or less used to reduce network requests. There are many cache frameworks developed with Objective-C on the network, but the cache framework developed by swift is relatively less. Swiftlycache is a cache framework developed by me(https://github.com/hlc0000/SwiftlyCache)

Features:
Support all data types complying with the codable protocol
Objects can be evicted with least-recently-used algorithm
It can be configured to automatically recycle objects or manually recycle objects when receiving memory warnings or when the application enters the background
Using subscript can make reading and writing data more convenient
Support reading data using sequence generator

Division of responsibilities of members:
Cacheware: it provides some basic interface protocols. Multicache, memorycache, diskcache, etc. all abide by this protocol
Multicache: multicache, call memorycache and diskcache related methods
Memorycache: it is responsible for small capacity, relatively high-speed memory cache, thread safety, asynchronous operation, automatic and manual cache cleaning
Memorystorage: the bidirectional linked list class used by memorycache
Linkednode: double linked list node class
Diskcache: responsible for handling large capacity, relatively low speed disk cache, thread safety, asynchronous operation support, automatic and manual cache cleaning
Diskstorage: diskcache internal implementation class
Diskstorageitem: used to load disk cache data

If you are interested, you can go to my GitHub to learn more details. You can see the performance comparison between swiftlycache and other caches... If you can support it, it will be my great honor. Thank you

Top comments (0)