RBDataPersistentCache Class Reference

Inherits from NSObject
Declared in RBDataPersistentCache.h

Overview

A cache that persists items to disk.

  isValid

Whether or not the cache is valid or an error occurred and the cache is invalid.

@property (nonatomic, readonly) BOOL isValid

Discussion

Whether or not the cache is valid or an error occurred and the cache is invalid.

Declared In

RBDataPersistentCache.h

  error

The error that occurred if the cache is invalid.

@property (nonatomic, readonly, nullable) NSError *error

Discussion

The error that occurred if the cache is invalid.

Declared In

RBDataPersistentCache.h

  storagePath

The path to which items are stored.

@property (nonatomic, readonly, nonnull) NSString *storagePath

Discussion

The path to which items are stored.

Declared In

RBDataPersistentCache.h

  maximumCacheSizeInBytes

The maximum size in bytes of the cache.

@property (nonatomic, readonly) NSUInteger maximumCacheSizeInBytes

Discussion

The maximum size in bytes of the cache.

Declared In

RBDataPersistentCache.h

  cacheSizeInBytes

The current size of the cache in bytes.

@property (atomic, readonly) NSUInteger cacheSizeInBytes

Discussion

The current size of the cache in bytes.

Declared In

RBDataPersistentCache.h

– init

Initializes a new persistent cache with default settings.

- (nonnull instancetype)init

Return Value

The initialized persistent cache.

Discussion

Initializes a new persistent cache with default settings.

Declared In

RBDataPersistentCache.h

– initWithStoragePath:maximumCacheSize:namespace:

Initializes a new persistent cache with the given settings.

- (nonnull instancetype)initWithStoragePath:(nonnull NSString *)storagePath maximumCacheSize:(NSUInteger)maximumCacheSizeInBytes namespace:(nonnull NSString *)ns

Parameters

storagePath

The path at which to store items.

maximumCacheSizeInBytes

The maximum size of the cache in bytes.

ns

The namespace of the cache.

Return Value

The initialized cache.

Discussion

Initializes a new persistent cache with the given settings.

Declared In

RBDataPersistentCache.h

– storeDataItem:key:group:expiryInterval:completion:

Asynchronously stores the given data item.

- (void)storeDataItem:(nonnull NSData *)dataItem key:(nonnull NSString *)key group:(nullable NSString *)group expiryInterval:(NSTimeInterval)expiryInterval completion:(nullable dispatch_block_t)completion

Parameters

dataItem

The data item to store.

key

The unique key to store the item with.

group

The group in which to store the item (optional).

expiryInterval

The time span after which the item expires.

completion

An optional block to be called when storage is complete.

Discussion

Asynchronously stores the given data item.

Declared In

RBDataPersistentCache.h

– dataItemExistsWithKey:

Determines whether a non-expired item is stored for the given key.

- (BOOL)dataItemExistsWithKey:(nonnull NSString *)key

Parameters

key

The key to search for.

Return Value

Whether or not an item was found.

Discussion

Determines whether a non-expired item is stored for the given key.

Declared In

RBDataPersistentCache.h

– fetchDataItemWithKey:completion:

Determines whether a non-expired item is stored for the given key.

- (void)fetchDataItemWithKey:(nonnull NSString *)key completion:(nonnull void ( ^ ) ( NSData *__nullable data ))completion

Parameters

key

The key to search for.

completion

The completion block that is called with the result.

Discussion

Determines whether a non-expired item is stored for the given key.

Declared In

RBDataPersistentCache.h

– removeDataItemWithKey:

Removes the data item stored with the given key.

- (void)removeDataItemWithKey:(nonnull NSString *)key

Parameters

key

The key with which the item stored is to be removed.

Discussion

Removes the data item stored with the given key.

Declared In

RBDataPersistentCache.h

– removeAllItemsWithGroup:

Removes all stored data items in the given group.

- (void)removeAllItemsWithGroup:(nonnull NSString *)group

Parameters

group

The group to remove all stored data items in.

Discussion

Removes all stored data items in the given group.

Declared In

RBDataPersistentCache.h

– removeAllExpiredItems

Removes all stored data items in the cache.

- (void)removeAllExpiredItems

Discussion

Removes all stored data items in the cache.

Declared In

RBDataPersistentCache.h