Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skyfe79/tinycache
Simple and lightweight caching solution for Swift apps.
https://github.com/skyfe79/tinycache
ios macos swift
Last synced: 10 days ago
JSON representation
Simple and lightweight caching solution for Swift apps.
- Host: GitHub
- URL: https://github.com/skyfe79/tinycache
- Owner: skyfe79
- License: mit
- Created: 2024-03-26T14:06:51.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-27T07:32:36.000Z (8 months ago)
- Last Synced: 2024-04-16T12:09:48.079Z (7 months ago)
- Topics: ios, macos, swift
- Language: Swift
- Homepage: https://github.com/skyfe79/TinyCache
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TinyCache
TinyCache is a simple and lightweight caching solution for Swift apps.
## Installation
### Swift Package Manager
To integrate TinyCache into your project using Swift Package Manager, add it to your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/skyfe79/TinyCache.git", .upToNextMajor(from: "0.0.1"))
]
```## Usage
### Memory Caching
```swift
let tinyCache = TinyCache(policy: .default)
tinyCache.set(value: "Hello, World!", forKey: "greeting")
let greeting = tinyCache.value(forKey: "greeting")
```### Codable Caching
```swift
struct MyModel: Codable {
let id: Int
let name: String
}let codableCache = TinyCodableCache.shared
let model = MyModel(id: 1, name: "TinyCache")
codableCache.set(codable: model, forKey: "modelKey")
```### Image Caching
```swift
let imageCache = TinyImageCache.shared
imageCache.set(image: myImage, forKey: "imageKey")
```## License
TinyCache is released under the MIT License. See LICENSE for details.