Skip to content

Releases: 0xLeif/Cache

2.1.2

20 Sep 21:05
ff7c208

Choose a tag to compare

What's Changed

  • Update GitHub Actions workflow for DocC build by @0xLeif in #23
  • Add dependency for swift-docc-plugin by @0xLeif in #24

Full Changelog: 2.1.1...2.1.2

2.1.1

20 Sep 20:14
9471103

Choose a tag to compare

What's Changed

  • Update windows.yml by @0xLeif in #17
  • Update for Swift 6 with thread safety improvements by @0xLeif in #20
  • Update LICENSE by @0xLeif in #19
  • Refactor Cache locking mechanism to use NSRecursiveLock for improved thread safety and prevent deadlocks. Added comprehensive thread safety tests to validate the fix and ensure no new locking issues are introduced. by @0xLeif in #22

Full Changelog: 2.1.0...2.1.1

2.1.0

22 Jul 17:39
a535c68

Choose a tag to compare

What's Changed

PersistableCache

Breaking Change

  • Update PersistableCache to use mappings by @0xLeif in #13

Full Changelog: 2.0.0...2.1.0

2.0.0

07 Jul 20:00
d6d6325

Choose a tag to compare

What's Changed

Added

  • AnyCacheable type, enabling type erasure for any Cacheable object.
  • CacheInitializable protocol, introducing an initializer for Cacheable objects.
  • ComposableCache type, allowing for the composition of multiple caches into a single cache.
  • Logging property wrapper, providing a convenient way to cache and retrieve loggers.
  • Global.loggers cache, a required cache instance specifically designed for managing loggers.

Full Changelog: 1.6.0...2.0.0

1.6.0

29 Jun 03:12
a3f81b1

Choose a tag to compare

Adds

  • RequiredKeysCache: Introduced a new cache type, RequiredKeysCache, that ensures all specified keys are present in the cache at all times. This cache is useful when you have a defined set of keys that must always be present.

  • Global Caches: Added three global cache instances to simplify usage:

    • cache: A global cache instance for generic caching needs.
    • images: A global cache instance specifically designed for storing and retrieving images.
    • dependencies: A global cache instance for storing and retrieving dependencies.
  • Property Wrappers: Added three new property wrappers for easy cache integration:

  • Cached: A property wrapper that automatically retrieves and caches the value from the associated cache.

  • OptionallyCached: A property wrapper that retrieves the value from the associated cache if available, or falls back to the default value.

  • Resolved: A property wrapper that resolves the value from the associated cache, throwing an error if the value is missing or cannot be resolved.

With these additions, the Cache library becomes even more versatile and convenient to use. Happy caching!

Test Coverage for Windows and Linux

  • Added tests for Windows platform to ensure compatibility and functionality on the Windows operating system.

  • Added tests for Linux platform to ensure compatibility and functionality on the Linux operating system.


What's Changed

Full Changelog: 1.5.0...1.6.0

1.5.0

10 Jun 23:39
5a797f4

Choose a tag to compare

LRUCache

LRUCache is a key-value store that uses the Least Recently Used (LRU) algorithm to evict items when the cache capacity is exceeded. This implementation is written in Swift and can be used in any iOS, macOS, or tvOS project. The cache contents are automatically loaded from the initial values dictionary when initialized.

The LRUCache is implemented as a subclass of the Cache class. You can use its capacity property to specify the maximum number of key-value pairs that the cache can hold. When the cache capacity is exceeded, the least recently used item is automatically evicted from the cache.


What's Changed

Full Changelog: 1.4.0...1.5.0

1.4.0

10 Jun 21:22
e8bb8f8

Choose a tag to compare

PersistableCache

The PersistableCache class is a cache that stores its contents persistently on disk using a JSON file. Use it to create a cache that persists its contents between application launches. The cache contents are automatically loaded from disk when initialized, and can be saved manually whenever required.

To use PersistableCache, make sure that the specified key type conforms to both RawRepresentable and Hashable protocols. The RawValue of Key must be a String type.

Here's an example of creating a cache, setting a value, and saving it to disk:

let cache = PersistableCache<String, Double>()

cache["pi"] = Double.pi

do {
    try cache.save()
} catch {
    print("Failed to save cache: \(error)")
}

You can also load a previously saved cache from disk:

let cache = PersistableCache<String, Double>()

let pi = cache["pi"] // pi == Double.pi

Remember that the save() function may throw errors if the encoder fails to serialize the cache to JSON or the disk write operation fails. Make sure to handle the errors appropriately.


What's Changed

Full Changelog: 1.3.0...1.4.0

1.3.0

10 Jun 04:36
538f770

Choose a tag to compare

What's Changed

  • Add dictionary extensions and Cacheable by @0xLeif in #4

Full Changelog: 1.2.0...1.3.0

1.2.0

10 Jun 01:21
a1ad092

Choose a tag to compare

What's Changed

Full Changelog: 1.1.0...1.2.0

1.1.0

09 Jun 22:15
6ddb9ec

Choose a tag to compare

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