Tuya iOS Smart Life App SDK 5.15.0
ThingEncryptDiskCache Class Reference

#import <ThingEncryptDiskCache.h>

Inheritance diagram for ThingEncryptDiskCache:

Instance Methods

(instancetype) - UNAVAILABLE_ATTRIBUTE
 
(nullable instancetype) - initWithPath:
 
(BOOL) - containsObjectForKey:
 
(void) - containsObjectForKey:withBlock:
 
(nullable id< NSCoding >) - objectForKey:
 
(void) - objectForKey:withBlock:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withBlock:
 
(void) - removeObjectForKey:
 
(void) - removeObjectForKey:withBlock:
 
(void) - removeAllObjects
 
(void) - removeAllObjectsWithBlock:
 
(void) - removeObjectsAtPath:
 
(NSInteger) - totalCount
 
(void) - totalCountWithBlock:
 
(NSInteger) - totalCost
 
(void) - totalCostWithBlock:
 
(nullable NSString *) - cachedFileNameForKey:
 
(void) - trimToCost:
 
(void) - trimToCost:withBlock:
 
(void) - trimToAge:
 
(void) - trimToAge:withBlock:
 
(NSString *(^)) - customFileNameBlock
 
(instancetype) - UNAVAILABLE_ATTRIBUTE
 
(nullable instancetype) - initWithPath:
 
(BOOL) - containsObjectForKey:
 
(void) - containsObjectForKey:withBlock:
 
(nullable id< NSCoding >) - objectForKey:
 
(void) - objectForKey:withBlock:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withBlock:
 
(void) - removeObjectForKey:
 
(void) - removeObjectForKey:withBlock:
 
(void) - removeAllObjects
 
(void) - removeAllObjectsWithBlock:
 
(void) - removeObjectsAtPath:
 
(NSInteger) - totalCount
 
(void) - totalCountWithBlock:
 
(NSInteger) - totalCost
 
(void) - totalCostWithBlock:
 
(nullable NSString *) - cachedFileNameForKey:
 
(void) - trimToCost:
 
(void) - trimToCost:withBlock:
 
(void) - trimToAge:
 
(void) - trimToAge:withBlock:
 
(NSString *(^)) - customFileNameBlock
 
(instancetype) - UNAVAILABLE_ATTRIBUTE
 
(nullable instancetype) - initWithPath:
 
(BOOL) - containsObjectForKey:
 
(void) - containsObjectForKey:withBlock:
 
(nullable id< NSCoding >) - objectForKey:
 
(void) - objectForKey:withBlock:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withBlock:
 
(void) - removeObjectForKey:
 
(void) - removeObjectForKey:withBlock:
 
(void) - removeAllObjects
 
(void) - removeAllObjectsWithBlock:
 
(void) - removeObjectsAtPath:
 
(NSInteger) - totalCount
 
(void) - totalCountWithBlock:
 
(NSInteger) - totalCost
 
(void) - totalCostWithBlock:
 
(nullable NSString *) - cachedFileNameForKey:
 
(void) - trimToCost:
 
(void) - trimToCost:withBlock:
 
(void) - trimToAge:
 
(void) - trimToAge:withBlock:
 
(NSString *(^)) - customFileNameBlock
 
(instancetype) - UNAVAILABLE_ATTRIBUTE
 
(nullable instancetype) - initWithPath:
 
(BOOL) - containsObjectForKey:
 
(void) - containsObjectForKey:withBlock:
 
(nullable id< NSCoding >) - objectForKey:
 
(void) - objectForKey:withBlock:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withBlock:
 
(void) - removeObjectForKey:
 
(void) - removeObjectForKey:withBlock:
 
(void) - removeAllObjects
 
(void) - removeAllObjectsWithBlock:
 
(void) - removeObjectsAtPath:
 
(NSInteger) - totalCount
 
(void) - totalCountWithBlock:
 
(NSInteger) - totalCost
 
(void) - totalCostWithBlock:
 
(nullable NSString *) - cachedFileNameForKey:
 
(void) - trimToCost:
 
(void) - trimToCost:withBlock:
 
(void) - trimToAge:
 
(void) - trimToAge:withBlock:
 

Class Methods

(instancetype) + UNAVAILABLE_ATTRIBUTE
 
(nullable NSData *) + getExtendedDataFromObject:
 
(void) + setExtendedData:toObject:
 
(instancetype) + UNAVAILABLE_ATTRIBUTE
 
(nullable NSData *) + getExtendedDataFromObject:
 
(void) + setExtendedData:toObject:
 
(instancetype) + UNAVAILABLE_ATTRIBUTE
 
(nullable NSData *) + getExtendedDataFromObject:
 
(void) + setExtendedData:toObject:
 
(instancetype) + UNAVAILABLE_ATTRIBUTE
 
(nullable NSData *) + getExtendedDataFromObject:
 
(void) + setExtendedData:toObject:
 

Properties

NSString * name
 
NSString * path
 
NSString * dataDirectory
 
NSString *(^ customFileNameBlock )(NSString *key)
 
NSUInteger countLimit
 
NSUInteger costLimit
 
NSTimeInterval ageLimit
 
NSUInteger freeDiskSpaceLimit
 
NSTimeInterval autoTrimInterval
 
BOOL errorLogsEnabled
 

Detailed Description

Definition at line 13 of file ThingEncryptDiskCache.h.

Method Documentation

◆ cachedFileNameForKey: [1/4]

- (nullable NSString *) cachedFileNameForKey: (nullable NSString *)  key

When an object needs to be saved as a file, this function will be invoked to generate a file name use md5(key) as default file name.

◆ cachedFileNameForKey: [2/4]

- (nullable NSString *) cachedFileNameForKey: (nullable NSString *)  key

When an object needs to be saved as a file, this function will be invoked to generate a file name use md5(key) as default file name.

◆ cachedFileNameForKey: [3/4]

- (nullable NSString *) cachedFileNameForKey: (nullable NSString *)  key

When an object needs to be saved as a file, this function will be invoked to generate a file name use md5(key) as default file name.

◆ cachedFileNameForKey: [4/4]

- (nullable NSString *) cachedFileNameForKey: (nullable NSString *)  key

When an object needs to be saved as a file, this function will be invoked to generate a file name use md5(key) as default file name.

◆ containsObjectForKey: [1/4]

- (BOOL) containsObjectForKey: (NSString *)  key

=============================================================================

@name Access Methods

Returns a boolean value that indicates whether a given key is in cache. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return NO.
Returns
Whether the key is in cache.

◆ containsObjectForKey: [2/4]

- (BOOL) containsObjectForKey: (NSString *)  key

=============================================================================

@name Access Methods

Returns a boolean value that indicates whether a given key is in cache. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return NO.
Returns
Whether the key is in cache.

◆ containsObjectForKey: [3/4]

- (BOOL) containsObjectForKey: (NSString *)  key

=============================================================================

@name Access Methods

Returns a boolean value that indicates whether a given key is in cache. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return NO.
Returns
Whether the key is in cache.

◆ containsObjectForKey: [4/4]

- (BOOL) containsObjectForKey: (NSString *)  key

=============================================================================

@name Access Methods

Returns a boolean value that indicates whether a given key is in cache. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return NO.
Returns
Whether the key is in cache.

◆ containsObjectForKey:withBlock: [1/4]

- (void) containsObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, BOOL contains))  block 

Returns a boolean value with the block that indicates whether a given key is in cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return NO.
blockA block which will be invoked in background queue when finished.

◆ containsObjectForKey:withBlock: [2/4]

- (void) containsObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, BOOL contains))  block 

Returns a boolean value with the block that indicates whether a given key is in cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return NO.
blockA block which will be invoked in background queue when finished.

◆ containsObjectForKey:withBlock: [3/4]

- (void) containsObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, BOOL contains))  block 

Returns a boolean value with the block that indicates whether a given key is in cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return NO.
blockA block which will be invoked in background queue when finished.

◆ containsObjectForKey:withBlock: [4/4]

- (void) containsObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, BOOL contains))  block 

Returns a boolean value with the block that indicates whether a given key is in cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return NO.
blockA block which will be invoked in background queue when finished.

◆ customFileNameBlock [1/3]

- (NSString *(^)) customFileNameBlock (NSString *)  key

When an object needs to be saved as a file, this block will be invoked to generate a file name for a specified key. If the block is nil, the cache use md5(key) as default file name.

The default value is nil.

◆ customFileNameBlock [2/3]

- (NSString *(^)) customFileNameBlock (NSString *)  key

When an object needs to be saved as a file, this block will be invoked to generate a file name for a specified key. If the block is nil, the cache use md5(key) as default file name.

The default value is nil.

◆ customFileNameBlock [3/3]

- (NSString *(^)) customFileNameBlock (NSString *)  key

When an object needs to be saved as a file, this block will be invoked to generate a file name for a specified key. If the block is nil, the cache use md5(key) as default file name.

The default value is nil.

◆ getExtendedDataFromObject: [1/4]

+ (nullable NSData *) getExtendedDataFromObject: (id)  object

=============================================================================

@name Extended Data

Get extended data from an object.

@discussion See 'setExtendedData:toObject:' for more information.

Parameters
objectAn object.
Returns
The extended data.

◆ getExtendedDataFromObject: [2/4]

+ (nullable NSData *) getExtendedDataFromObject: (id)  object

=============================================================================

@name Extended Data

Get extended data from an object.

@discussion See 'setExtendedData:toObject:' for more information.

Parameters
objectAn object.
Returns
The extended data.

◆ getExtendedDataFromObject: [3/4]

+ (nullable NSData *) getExtendedDataFromObject: (id)  object

=============================================================================

@name Extended Data

Get extended data from an object.

@discussion See 'setExtendedData:toObject:' for more information.

Parameters
objectAn object.
Returns
The extended data.

◆ getExtendedDataFromObject: [4/4]

+ (nullable NSData *) getExtendedDataFromObject: (id)  object

=============================================================================

@name Extended Data

Get extended data from an object.

@discussion See 'setExtendedData:toObject:' for more information.

Parameters
objectAn object.
Returns
The extended data.

◆ initWithPath: [1/4]

- (nullable instancetype) initWithPath: (NSString *)  NS_DESIGNATED_INITIALIZER

Create a new cache based on the specified path.

Parameters
pathFull path of a directory in which the cache will write data. Once initialized you should not read and write to this directory.
Returns
A new cache object, or nil if an error occurs.
Warning
If the cache instance for the specified path already exists in memory, this method will return it directly, instead of creating a new instance.

◆ initWithPath: [2/4]

- (nullable instancetype) initWithPath: (NSString *)  NS_DESIGNATED_INITIALIZER

Create a new cache based on the specified path.

Parameters
pathFull path of a directory in which the cache will write data. Once initialized you should not read and write to this directory.
Returns
A new cache object, or nil if an error occurs.
Warning
If the cache instance for the specified path already exists in memory, this method will return it directly, instead of creating a new instance.

◆ initWithPath: [3/4]

- (nullable instancetype) initWithPath: (NSString *)  NS_DESIGNATED_INITIALIZER

Create a new cache based on the specified path.

Parameters
pathFull path of a directory in which the cache will write data. Once initialized you should not read and write to this directory.
Returns
A new cache object, or nil if an error occurs.
Warning
If the cache instance for the specified path already exists in memory, this method will return it directly, instead of creating a new instance.

◆ initWithPath: [4/4]

- (nullable instancetype) initWithPath: (NSString *)  NS_DESIGNATED_INITIALIZER

Create a new cache based on the specified path.

Parameters
pathFull path of a directory in which the cache will write data. Once initialized you should not read and write to this directory.
Returns
A new cache object, or nil if an error occurs.
Warning
If the cache instance for the specified path already exists in memory, this method will return it directly, instead of creating a new instance.

◆ objectForKey: [1/4]

- (nullable id< NSCoding >) objectForKey: (NSString *)  key

Returns the value associated with a given key. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return nil.
Returns
The value associated with key, or nil if no value is associated with key.

◆ objectForKey: [2/4]

- (nullable id< NSCoding >) objectForKey: (NSString *)  key

Returns the value associated with a given key. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return nil.
Returns
The value associated with key, or nil if no value is associated with key.

◆ objectForKey: [3/4]

- (nullable id< NSCoding >) objectForKey: (NSString *)  key

Returns the value associated with a given key. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return nil.
Returns
The value associated with key, or nil if no value is associated with key.

◆ objectForKey: [4/4]

- (nullable id< NSCoding >) objectForKey: (NSString *)  key

Returns the value associated with a given key. This method may blocks the calling thread until file read finished.

Parameters
keyA string identifying the value. If nil, just return nil.
Returns
The value associated with key, or nil if no value is associated with key.

◆ objectForKey:withBlock: [1/4]

- (void) objectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, id< NSCoding > _Nullable object))  block 

Returns the value associated with a given key. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return nil.
blockA block which will be invoked in background queue when finished.

◆ objectForKey:withBlock: [2/4]

- (void) objectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, id< NSCoding > _Nullable object))  block 

Returns the value associated with a given key. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return nil.
blockA block which will be invoked in background queue when finished.

◆ objectForKey:withBlock: [3/4]

- (void) objectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, id< NSCoding > _Nullable object))  block 

Returns the value associated with a given key. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return nil.
blockA block which will be invoked in background queue when finished.

◆ objectForKey:withBlock: [4/4]

- (void) objectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key, id< NSCoding > _Nullable object))  block 

Returns the value associated with a given key. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyA string identifying the value. If nil, just return nil.
blockA block which will be invoked in background queue when finished.

◆ removeAllObjects [1/4]

- (void) removeAllObjects

Empties the cache. This method may blocks the calling thread until file delete finished.

◆ removeAllObjects [2/4]

- (void) removeAllObjects

Empties the cache. This method may blocks the calling thread until file delete finished.

◆ removeAllObjects [3/4]

- (void) removeAllObjects

Empties the cache. This method may blocks the calling thread until file delete finished.

◆ removeAllObjects [4/4]

- (void) removeAllObjects

Empties the cache. This method may blocks the calling thread until file delete finished.

◆ removeAllObjectsWithBlock: [1/4]

- (void) removeAllObjectsWithBlock: (void(^)(void))  block

Empties the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ removeAllObjectsWithBlock: [2/4]

- (void) removeAllObjectsWithBlock: (void(^)(void))  block

Empties the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ removeAllObjectsWithBlock: [3/4]

- (void) removeAllObjectsWithBlock: (void(^)(void))  block

Empties the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ removeAllObjectsWithBlock: [4/4]

- (void) removeAllObjectsWithBlock: (void(^)(void))  block

Empties the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ removeObjectForKey: [1/4]

- (void) removeObjectForKey: (NSString *)  key

Removes the value of the specified key in the cache. This method may blocks the calling thread until file delete finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.

◆ removeObjectForKey: [2/4]

- (void) removeObjectForKey: (NSString *)  key

Removes the value of the specified key in the cache. This method may blocks the calling thread until file delete finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.

◆ removeObjectForKey: [3/4]

- (void) removeObjectForKey: (NSString *)  key

Removes the value of the specified key in the cache. This method may blocks the calling thread until file delete finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.

◆ removeObjectForKey: [4/4]

- (void) removeObjectForKey: (NSString *)  key

Removes the value of the specified key in the cache. This method may blocks the calling thread until file delete finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.

◆ removeObjectForKey:withBlock: [1/4]

- (void) removeObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key))  block 

Removes the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.
blockA block which will be invoked in background queue when finished.

◆ removeObjectForKey:withBlock: [2/4]

- (void) removeObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key))  block 

Removes the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.
blockA block which will be invoked in background queue when finished.

◆ removeObjectForKey:withBlock: [3/4]

- (void) removeObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key))  block 

Removes the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.
blockA block which will be invoked in background queue when finished.

◆ removeObjectForKey:withBlock: [4/4]

- (void) removeObjectForKey: (NSString *)  key
withBlock: (void(^)(NSString *key))  block 

Removes the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
keyThe key identifying the value to be removed. If nil, this method has no effect.
blockA block which will be invoked in background queue when finished.

◆ removeObjectsAtPath: [1/4]

- (void) removeObjectsAtPath: (NSString *)  path

Remove all items under the given path in background queue.

◆ removeObjectsAtPath: [2/4]

- (void) removeObjectsAtPath: (NSString *)  path

Remove all items under the given path in background queue.

◆ removeObjectsAtPath: [3/4]

- (void) removeObjectsAtPath: (NSString *)  path

Remove all items under the given path in background queue.

◆ removeObjectsAtPath: [4/4]

- (void) removeObjectsAtPath: (NSString *)  path

Remove all items under the given path in background queue.

◆ setExtendedData:toObject: [1/4]

+ (void) setExtendedData: (nullable NSData *)  extendedData
toObject: (id)  object 

Set extended data to an object.

@discussion You can set any extended data to an object before you save the object to disk cache. The extended data will also be saved with this object. You can get the extended data later with "getExtendedDataFromObject:".

Parameters
extendedDataThe extended data (pass nil to remove).
objectThe object.

◆ setExtendedData:toObject: [2/4]

+ (void) setExtendedData: (nullable NSData *)  extendedData
toObject: (id)  object 

Set extended data to an object.

@discussion You can set any extended data to an object before you save the object to disk cache. The extended data will also be saved with this object. You can get the extended data later with "getExtendedDataFromObject:".

Parameters
extendedDataThe extended data (pass nil to remove).
objectThe object.

◆ setExtendedData:toObject: [3/4]

+ (void) setExtendedData: (nullable NSData *)  extendedData
toObject: (id)  object 

Set extended data to an object.

@discussion You can set any extended data to an object before you save the object to disk cache. The extended data will also be saved with this object. You can get the extended data later with "getExtendedDataFromObject:".

Parameters
extendedDataThe extended data (pass nil to remove).
objectThe object.

◆ setExtendedData:toObject: [4/4]

+ (void) setExtendedData: (nullable NSData *)  extendedData
toObject: (id)  object 

Set extended data to an object.

@discussion You can set any extended data to an object before you save the object to disk cache. The extended data will also be saved with this object. You can get the extended data later with "getExtendedDataFromObject:".

Parameters
extendedDataThe extended data (pass nil to remove).
objectThe object.

◆ setObject:forKey: [1/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key 

Sets the value of the specified key in the cache. This method may blocks the calling thread until file write finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
keyThe key with which to associate the value. If nil, this method has no effect.

◆ setObject:forKey: [2/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key 

Sets the value of the specified key in the cache. This method may blocks the calling thread until file write finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
keyThe key with which to associate the value. If nil, this method has no effect.

◆ setObject:forKey: [3/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key 

Sets the value of the specified key in the cache. This method may blocks the calling thread until file write finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
keyThe key with which to associate the value. If nil, this method has no effect.

◆ setObject:forKey: [4/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key 

Sets the value of the specified key in the cache. This method may blocks the calling thread until file write finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
keyThe key with which to associate the value. If nil, this method has no effect.

◆ setObject:forKey:withBlock: [1/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key
withBlock: (void(^)(void))  block 

Sets the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
blockA block which will be invoked in background queue when finished.

◆ setObject:forKey:withBlock: [2/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key
withBlock: (void(^)(void))  block 

Sets the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
blockA block which will be invoked in background queue when finished.

◆ setObject:forKey:withBlock: [3/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key
withBlock: (void(^)(void))  block 

Sets the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
blockA block which will be invoked in background queue when finished.

◆ setObject:forKey:withBlock: [4/4]

- (void) setObject: (nullable id< NSCoding >)  object
forKey: (NSString *)  key
withBlock: (void(^)(void))  block 

Sets the value of the specified key in the cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
objectThe object to be stored in the cache. If nil, it calls removeObjectForKey:.
blockA block which will be invoked in background queue when finished.

◆ totalCost [1/4]

- (NSInteger) totalCost

Returns the total cost (in bytes) of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects cost in bytes.

◆ totalCost [2/4]

- (NSInteger) totalCost

Returns the total cost (in bytes) of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects cost in bytes.

◆ totalCost [3/4]

- (NSInteger) totalCost

Returns the total cost (in bytes) of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects cost in bytes.

◆ totalCost [4/4]

- (NSInteger) totalCost

Returns the total cost (in bytes) of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects cost in bytes.

◆ totalCostWithBlock: [1/4]

- (void) totalCostWithBlock: (void(^)(NSInteger totalCost))  block

Get the total cost (in bytes) of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCostWithBlock: [2/4]

- (void) totalCostWithBlock: (void(^)(NSInteger totalCost))  block

Get the total cost (in bytes) of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCostWithBlock: [3/4]

- (void) totalCostWithBlock: (void(^)(NSInteger totalCost))  block

Get the total cost (in bytes) of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCostWithBlock: [4/4]

- (void) totalCostWithBlock: (void(^)(NSInteger totalCost))  block

Get the total cost (in bytes) of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCount [1/4]

- (NSInteger) totalCount

Returns the number of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects count.

◆ totalCount [2/4]

- (NSInteger) totalCount

Returns the number of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects count.

◆ totalCount [3/4]

- (NSInteger) totalCount

Returns the number of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects count.

◆ totalCount [4/4]

- (NSInteger) totalCount

Returns the number of objects in this cache. This method may blocks the calling thread until file read finished.

Returns
The total objects count.

◆ totalCountWithBlock: [1/4]

- (void) totalCountWithBlock: (void(^)(NSInteger totalCount))  block

Get the number of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCountWithBlock: [2/4]

- (void) totalCountWithBlock: (void(^)(NSInteger totalCount))  block

Get the number of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCountWithBlock: [3/4]

- (void) totalCountWithBlock: (void(^)(NSInteger totalCount))  block

Get the number of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ totalCountWithBlock: [4/4]

- (void) totalCountWithBlock: (void(^)(NSInteger totalCount))  block

Get the number of objects in this cache. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
blockA block which will be invoked in background queue when finished.

◆ trimToAge: [1/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method may blocks the calling thread until operation finished.

Parameters
ageThe maximum age of the object.

◆ trimToAge: [2/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method may blocks the calling thread until operation finished.

Parameters
ageThe maximum age of the object.

◆ trimToAge: [3/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method may blocks the calling thread until operation finished.

Parameters
ageThe maximum age of the object.

◆ trimToAge: [4/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method may blocks the calling thread until operation finished.

Parameters
ageThe maximum age of the object.

◆ trimToAge:withBlock: [1/4]

- (void) trimToAge: (NSTimeInterval)  age
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
ageThe maximum age of the object.
blockA block which will be invoked in background queue when finished.

◆ trimToAge:withBlock: [2/4]

- (void) trimToAge: (NSTimeInterval)  age
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
ageThe maximum age of the object.
blockA block which will be invoked in background queue when finished.

◆ trimToAge:withBlock: [3/4]

- (void) trimToAge: (NSTimeInterval)  age
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
ageThe maximum age of the object.
blockA block which will be invoked in background queue when finished.

◆ trimToAge:withBlock: [4/4]

- (void) trimToAge: (NSTimeInterval)  age
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until all expiry objects removed by the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
ageThe maximum age of the object.
blockA block which will be invoked in background queue when finished.

◆ trimToCost: [1/4]

- (void) trimToCost: (NSUInteger)  cost

=============================================================================

@name Trim

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method may blocks the calling thread until operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.

◆ trimToCost: [2/4]

- (void) trimToCost: (NSUInteger)  cost

=============================================================================

@name Trim

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method may blocks the calling thread until operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.

◆ trimToCost: [3/4]

- (void) trimToCost: (NSUInteger)  cost

=============================================================================

@name Trim

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method may blocks the calling thread until operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.

◆ trimToCost: [4/4]

- (void) trimToCost: (NSUInteger)  cost

=============================================================================

@name Trim

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method may blocks the calling thread until operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.

◆ trimToCost:withBlock: [1/4]

- (void) trimToCost: (NSUInteger)  cost
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.
blockA block which will be invoked in background queue when finished.

◆ trimToCost:withBlock: [2/4]

- (void) trimToCost: (NSUInteger)  cost
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.
blockA block which will be invoked in background queue when finished.

◆ trimToCost:withBlock: [3/4]

- (void) trimToCost: (NSUInteger)  cost
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.
blockA block which will be invoked in background queue when finished.

◆ trimToCost:withBlock: [4/4]

- (void) trimToCost: (NSUInteger)  cost
withBlock: (void(^)(void))  block 

Removes objects from the cache use LRU, until the totalCost is below the specified value. This method returns immediately and invoke the passed block in background queue when the operation finished.

Parameters
costThe total cost allowed to remain after the cache has been trimmed.
blockA block which will be invoked in background queue when finished.

◆ UNAVAILABLE_ATTRIBUTE [1/8]

+ (instancetype) UNAVAILABLE_ATTRIBUTE

◆ UNAVAILABLE_ATTRIBUTE [2/8]

- (instancetype) UNAVAILABLE_ATTRIBUTE

=============================================================================

@name Initializer

◆ UNAVAILABLE_ATTRIBUTE [3/8]

- (instancetype) UNAVAILABLE_ATTRIBUTE

=============================================================================

@name Initializer

◆ UNAVAILABLE_ATTRIBUTE [4/8]

+ (instancetype) UNAVAILABLE_ATTRIBUTE

◆ UNAVAILABLE_ATTRIBUTE [5/8]

+ (instancetype) UNAVAILABLE_ATTRIBUTE

◆ UNAVAILABLE_ATTRIBUTE [6/8]

- (instancetype) UNAVAILABLE_ATTRIBUTE

=============================================================================

@name Initializer

◆ UNAVAILABLE_ATTRIBUTE [7/8]

+ (instancetype) UNAVAILABLE_ATTRIBUTE

◆ UNAVAILABLE_ATTRIBUTE [8/8]

- (instancetype) UNAVAILABLE_ATTRIBUTE

=============================================================================

@name Initializer

Property Documentation

◆ ageLimit

- (NSTimeInterval) ageLimit
readwriteatomic

The maximum expiry time of objects in cache.

@discussion The default value is DBL_MAX, which means no limit. This is not a strict limit — if an object goes over the limit, the objects could be evicted later in background queue.

Definition at line 70 of file ThingEncryptDiskCache.h.

◆ autoTrimInterval

- (NSTimeInterval) autoTrimInterval
readwriteatomic

The auto trim check time interval in seconds. Default is 60 (1 minute).

@discussion The cache holds an internal timer to check whether the cache reaches its limits, and if the limit is reached, it begins to evict objects.

Definition at line 88 of file ThingEncryptDiskCache.h.

◆ costLimit

- (NSUInteger) costLimit
readwriteatomic

The maximum total cost that the cache can hold before it starts evicting objects.

@discussion The default value is NSUIntegerMax, which means no limit. This is not a strict limit — if the cache goes over the limit, some objects in the cache could be evicted later in background queue.

Definition at line 61 of file ThingEncryptDiskCache.h.

◆ countLimit

- (NSUInteger) countLimit
readwriteatomic

=============================================================================

@name Limit

The maximum number of objects the cache should hold.

@discussion The default value is NSUIntegerMax, which means no limit. This is not a strict limit — if the cache goes over the limit, some objects in the cache could be evicted later in background queue.

=============================================================================

@name Limit

The maximum number of objects the cache should hold.

@discussion The default value is NSUIntegerMax, which means no limit. This is not a strict limit — if the cache goes over the limit, some objects in the cache could be evicted later in background queue.

=============================================================================

@name Limit

The maximum number of objects the cache should hold.

@discussion The default value is NSUIntegerMax, which means no limit. This is not a strict limit — if the cache goes over the limit, some objects in the cache could be evicted later in background queue.

=============================================================================

@name Limit

The maximum number of objects the cache should hold.

@discussion The default value is NSUIntegerMax, which means no limit. This is not a strict limit — if the cache goes over the limit, some objects in the cache could be evicted later in background queue.

Definition at line 52 of file ThingEncryptDiskCache.h.

◆ customFileNameBlock

- (NSString *(^ customFileNameBlock) (NSString *key))
readwriteatomiccopy

When an object needs to be saved as a file, this block will be invoked to generate a file name for a specified key. If the block is nil, the cache use md5(key) as default file name.

The default value is nil.

◆ dataDirectory

- (NSString *) dataDirectory
readatomicassign

The path of the cache data (read-only).

Definition at line 27 of file ThingEncryptDiskCache.h.

◆ errorLogsEnabled

- (BOOL) errorLogsEnabled
readwriteatomic

Set YES to enable error logs for debug.

Definition at line 93 of file ThingEncryptDiskCache.h.

◆ freeDiskSpaceLimit

- (NSUInteger) freeDiskSpaceLimit
readwriteatomic

The minimum free disk space (in bytes) which the cache should kept.

@discussion The default value is 0, which means no limit. If the free disk space is lower than this value, the cache will remove objects to free some disk space. This is not a strict limit—if the free disk space goes over the limit, the objects could be evicted later in background queue.

Definition at line 80 of file ThingEncryptDiskCache.h.

◆ name

- (NSString *) name
readwriteatomiccopy

=============================================================================

@name Attribute

The name of the cache. Default is nil.

=============================================================================

@name Attribute

The name of the cache. Default is nil.

=============================================================================

@name Attribute

The name of the cache. Default is nil.

=============================================================================

@name Attribute

The name of the cache. Default is nil.

Definition at line 21 of file ThingEncryptDiskCache.h.

◆ path

- (NSString *) path
readatomicassign

The path of the cache (read-only).

Definition at line 24 of file ThingEncryptDiskCache.h.


The documentation for this class was generated from the following files: