Skip to content

Repository files navigation

Cache

💾 Simple memory & disk cache

Usage

🧑‍💻 Default

letcache=Cache<String>()try memory.save("MyValue", forKey:"MyKey")letcached=try cache.value(forKey:"MyKey")

🚀 Advanced

You can also use custom object with Codable

structCustomObject:Codable{letvalue:Int}letmemory=MemoryCache<CustomObject>(countLimit:100)letdisk=DiskCache<CustomObject>(fileManager: fileManager)letcache=Cache<CustomObject>(memory: memory, disk: disk)try cache.save(CustomObject(value:0), forKey:"MyKey")letcached=try cache.value(forKey:"MyKey")

♻️ Flow

Load value

  1. Load memory cache if available
  2. Load disk cache if available 2-1. then, save to memory cache if value existed in disk cache

Save value

  1. Save memory & cache

🧰 Installation

  1. In your Xcode project, navigate to File > Swift Packages > Add Package Dependancy...
  2. Paste the following into the URL field: https://github.com/cozzin/Cache

About

💾 Simple memory & disk cache

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages