Skip to content

1.1.0

Compare
Choose a tag to compare
@0xLeif 0xLeif released this 09 Jun 22:15
· 13 commits to main since this release
6ddb9ec

ExpiringCache

The ExpiringCache class is a cache that retains and returns objects for a specific duration set by the ExpirationDuration enumeration. Objects stored in the cache are automatically removed when their expiration duration has passed.

Usage

// Create an instance of the cache with a duration of 5 minutes
let cache = ExpiringCache<String, Int>(duration: .minutes(5))

// Store a value in the cache with a key
cache["Answer"] = 42

// Retrieve a value from the cache using its key
if let answer = cache["Answer"] {
    print("The answer is \(answer)")
}

Expiration Duration

The expiration duration of the cache can be set with the ExpirationDuration enumeration, which has three cases: seconds, minutes, and hours. Each case takes a single UInt argument to represent the duration of that time unit.


What's Changed

Full Changelog: 1.0.1...1.1.0