Swiftpack.co - EthanLipnik/Sebu as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by EthanLipnik.
EthanLipnik/Sebu 1.0.12
Easy caching for codable objects
⭐️ 4
🕓 1 year ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/EthanLipnik/Sebu.git", from: "1.0.12")

Sebu

Easy caching for codable objects.

How does it store?

Sebu uses JSON to store objects in the app's cache directory.

Usage

Save

Save object

let tweets = [Tweet()] // Your own object(s)
try Sebu.default.set(tweets,
              withName: "homeTimeline") // Your own cache name (overwrites by default)

Save object with expiration

try Sebu.default.set(tweets,
              withName: "homeTimeline",
              expiration: Calendar.current.date(byAdding: .minute, value: 5, to: Date())) // Expires in 5 minutes from now

Get

if let cache: [Tweet] = try? Sebu.default.get(withName: "homeTimeline") {
  self.tweets = cache
}

Clear cache

All cache

Sebu.default.clearAll()

Clear certain object

Sebu.default.clear("homeTimeline")

GitHub

link
Stars: 4
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics