Docs Build Status - Master Mac OS X Linux Apache 2 Slack Status


KituraCache is an in-memory, thread-safe cache which allows you to store objects against a unique, Hashable key.

To use KituraCache, import the package and initialise:

import KituraCache

let cache = KituraCache()

If no arguments are provided, the default cache will be non-expiring and a check will be made every 10 minutes to determine whether any entries need to be removed.

To add an entry to the cache, or update an entry if the key already exists:

In the following examples, item is a struct with an integer id field.

cache.setObject(item, forKey:

To retrieve an entry from the cache:

let cache = KituraCache()
if let item = cache.object(forKey: 1) {
    //Object with key of 1 retrieved from cache.
else {
    //No object stored in cache with key of 1.

To delete a single entry, pass the entry’s key as a parameter:

cache.removeObject(forKey: 1)

To reset the cache and its Statistics:


Refer to KituraCache and Statistics for more information.


This library is licensed under Apache 2.0. Full license text is available in LICENSE.