This library provides a cache mechanism relying on RxSwift. There are currently one storage implementation :
To install it, simply add the following line to your Podfile:
pod 'BeappCache'
- Declare an instance of RxCacheManager with the storage implementation desired
- Call
fromKey
method from RxCacheManager instance and define your key - Add your asynchronous operation into
.withAsync()
(⚠️ Must be a single observer) - Define your cache strategy into
.withStrategy()
- Fetch the result (Return an Observable)
let rxCacheManager = RxCacheManager()
rxCacheManager.fromKey(key: "key_xxx")
.withAsync(singleString)
.withStrategy(.justAsync)
.fetch()
RxCacheManager(verbose: true)
- Enable verbose log of RxCacheManager
RxCacheManager()
- Use the Cache librairy
- Cache configuration is by default
DiskConfig(name: "Floppy")
andMemoryConfig(expiry: .never, countLimit: 10, totalCostLimit: 10)
RxCacheManager(storageType: .cache(config: cacheConfig))
- Use the cache librairy
- Define your cache configuration like next
let cacheConfig = CacheStorageConfig(diskConfig: DiskConfig(name: "your_name"), memoryConfig: MemoryConfig(expiry: expiry, countLimit: Uint, totalCostLimit: Uint))
RxCacheManager(storageType: .custom(storage: YourExternalStorageProtocol()))
- Define your own
ExternalStorageProtocol
[BeappCache] [Cache] CacheWrapper with the key key_xxx saved
Success async request or data from cache
[BeappCache] [Cache] CacheWrapper with the key key_xxx saved
Success async request
[BeappCache] [Cache] CacheWrapper for key_xxx retrieved from cache
Success to get data from cache
Beapp, contact@beapp.fr
BeappCache is available under the MIT license. See the LICENSE file for more info.