TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Ben Bahrenburg.
Need caching? Focused on security? BucketList makes working with encrypted caching easy. Also supports stand your standard key value caching as well.
LockedBucket is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "BucketList"
Manually
Copy all *.swift
files contained in BucketList/Classes/
directory into your project.
There are six main classes in BucketList:
All of the Caching providers have a similar API, with the only difference being the secret field used in the secure protocols.
BucketList makes it easy to save items into cache. Below is an example on how to do this using the EncryptedDiskCache.
//Let's create an instance of the EncryptedDiskCache provider
//The first things we need to do is create a caching name. This will be the folder the files are cached within.
let cache = EncryptedDiskCache(cacheName: "foo")
//Now let's add a image to cache
let myImage = .....
let result = cache.add(secret: "a password", forKey: "my-secret-image", image: myImage)
print("Image was successfull added? \(result)")
//Now let's add a AnyObject to cache
let myObject = .....
let result = cache.add(secret: "a password", forKey: "my-secret-object", object: myObject)
print("myObject was successfull added? \(result)")
//Now let's add a Data to cache
let myData = .....
let result = cache.add(secret: "a password", forKey: "my-secret-data", data: myData)
print("myData was successfull added? \(result)")
You can easily get items from cache. Below is an example on how to do this using the EncryptedDiskCache.
//Let's create an instance of the EncryptedDiskCache provider
//The first things we need to do is create a caching name. This will be the folder the files are cached within.
let cache = EncryptedDiskCache(cacheName: "foo")
//Let's get our image from cache
let myImage = cache.getImage(secret: "a password", forKey: "my-secret-image")
//Now let's get our AnyObject from cache
let myObject = cache.getObject(secret: "a password", forKey: "my-secret-object")
print("myObject was successfull added? \(result)")
//Now let's get our Data from cache
let myData = cache.getData(secret: "a password", forKey: "my-secret-data")
You can easily check if items are already in cache using the exist function. Below is an example on how to do this using the EncryptedDiskCache.
//Let's create an instance of the EncryptedDiskCache provider
//The first things we need to do is create a caching name. This will be the folder the files are cached within.
let cache = EncryptedDiskCache(cacheName: "foo")
let isThere = cache.exists(forKey: "my-secret-image")
print("Is my image already in cache? \(isThere)")
You can also remove items from cache. Below is an example on how to do this using the EncryptedDiskCache.
//Let's create an instance of the EncryptedDiskCache provider
//The first things we need to do is create a caching name. This will be the folder the files are cached within.
let cache = EncryptedDiskCache(cacheName: "foo")
let wasRemoved = cache.remove(forKey: "my-secret-image")
print("Is my image was removed from cache? \(wasRemoved)")
You can empty all of your cache items easily. Below is an example on how to do this using the EncryptedDiskCache.
//Let's create an instance of the EncryptedDiskCache provider
//The first things we need to do is create a caching name. This will be the folder the files are cached within.
let cache = EncryptedDiskCache(cacheName: "foo")
let allRemoved = cache.empty()
print("All items removed from cache? \(allRemoved)")
Ben Bahrenburg, @bencoding
LockedBucket is available under the MIT license. See the LICENSE file for more details.