Swiftpack.co -  gorillka/Cache as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Cache provides composite in-memory and on-disk cache with LRU cleanup.
.package(url: "https://github.com/gorillka/Cache.git", from: "1.0.0")


Cache provides composite in-memory MemoryCache and on-disk PersistentCache cache with LRU cleanup.



Store, retrieve and remove object

let cache = MemoryCache<String>()
let key  = "loremKey"
let value = """
    The standard Lorem Ipsum passage, used since the 1500s

        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

        Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

// Store string
cache.insert(value, for: key)
// Retrive string
let retrivedValue = cache.value(for: key)
// Remove value
cache.removeValue(for: key)

Cost and count limit

MemoryCache discard a last recently cached value if either cost or count limit is reached.

// Configure cache
let cache = MemoryCache<String>(countLimit: 10, costLimit: .Mbyte(10))


You can use the Swift Package Manager by declaring Cache as a dependency in your Package.swift file:

.package(url: "https://github.com/gorillka/Cache", from: "1.0.0")

For more information, see the Swift Package Manager documentation.


Stars: 0
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

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