Tuya iOS Smart Life App SDK 5.15.0
ThingEncryptMemoryCache Class Reference

#import <ThingEncryptMemoryCache.h>

Inheritance diagram for ThingEncryptMemoryCache:

Instance Methods

(BOOL) - containsObjectForKey:
 
(nullable id) - objectForKey:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withCost:
 
(void) - removeObjectForKey:
 
(void) - removeAllObjects
 
(void) - trimToCount:
 
(void) - trimToCost:
 
(void) - trimToAge:
 
(void(^)) - didReceiveMemoryWarningBlock
 
(void(^)) - didEnterBackgroundBlock
 
(BOOL) - containsObjectForKey:
 
(nullable id) - objectForKey:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withCost:
 
(void) - removeObjectForKey:
 
(void) - removeAllObjects
 
(void) - trimToCount:
 
(void) - trimToCost:
 
(void) - trimToAge:
 
(void(^)) - didReceiveMemoryWarningBlock
 
(void(^)) - didEnterBackgroundBlock
 
(BOOL) - containsObjectForKey:
 
(nullable id) - objectForKey:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withCost:
 
(void) - removeObjectForKey:
 
(void) - removeAllObjects
 
(void) - trimToCount:
 
(void) - trimToCost:
 
(void) - trimToAge:
 
(void(^)) - didReceiveMemoryWarningBlock
 
(void(^)) - didEnterBackgroundBlock
 
(BOOL) - containsObjectForKey:
 
(nullable id) - objectForKey:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:withCost:
 
(void) - removeObjectForKey:
 
(void) - removeAllObjects
 
(void) - trimToCount:
 
(void) - trimToCost:
 
(void) - trimToAge:
 

Properties

NSString * name
 
NSUInteger totalCount
 
NSUInteger totalCost
 
NSUInteger countLimit
 
NSUInteger costLimit
 
NSTimeInterval ageLimit
 
NSTimeInterval autoTrimInterval
 
BOOL shouldRemoveAllObjectsOnMemoryWarning
 
BOOL shouldRemoveAllObjectsWhenEnteringBackground
 
void(^ didReceiveMemoryWarningBlock )(ThingEncryptMemoryCache *cache)
 
void(^ didEnterBackgroundBlock )(ThingEncryptMemoryCache *cache)
 
BOOL releaseOnMainThread
 
BOOL releaseAsynchronously
 

Detailed Description

Definition at line 13 of file ThingEncryptMemoryCache.h.

Method Documentation

◆ containsObjectForKey: [1/4]

- (BOOL) containsObjectForKey: (id)  key

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

@name Access Methods

Returns a Boolean value that indicates whether a given key is in cache.

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

◆ containsObjectForKey: [2/4]

- (BOOL) containsObjectForKey: (id)  key

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

@name Access Methods

Returns a Boolean value that indicates whether a given key is in cache.

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

◆ containsObjectForKey: [3/4]

- (BOOL) containsObjectForKey: (id)  key

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

@name Access Methods

Returns a Boolean value that indicates whether a given key is in cache.

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

◆ containsObjectForKey: [4/4]

- (BOOL) containsObjectForKey: (id)  key

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

@name Access Methods

Returns a Boolean value that indicates whether a given key is in cache.

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

◆ didEnterBackgroundBlock [1/3]

- (void(^)) didEnterBackgroundBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app enter background. The default value is nil.

◆ didEnterBackgroundBlock [2/3]

- (void(^)) didEnterBackgroundBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app enter background. The default value is nil.

◆ didEnterBackgroundBlock [3/3]

- (void(^)) didEnterBackgroundBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app enter background. The default value is nil.

◆ didReceiveMemoryWarningBlock [1/3]

- (void(^)) didReceiveMemoryWarningBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app receives a memory warning. The default value is nil.

◆ didReceiveMemoryWarningBlock [2/3]

- (void(^)) didReceiveMemoryWarningBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app receives a memory warning. The default value is nil.

◆ didReceiveMemoryWarningBlock [3/3]

- (void(^)) didReceiveMemoryWarningBlock (ThingEncryptMemoryCache *)  cache

A block to be executed when the app receives a memory warning. The default value is nil.

◆ objectForKey: [1/4]

- (nullable id) objectForKey: (id)  key

Returns the value associated with a given key.

Parameters
keyAn object 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) objectForKey: (id)  key

Returns the value associated with a given key.

Parameters
keyAn object 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) objectForKey: (id)  key

Returns the value associated with a given key.

Parameters
keyAn object 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) objectForKey: (id)  key

Returns the value associated with a given key.

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

◆ removeAllObjects [1/4]

- (void) removeAllObjects

Empties the cache immediately.

◆ removeAllObjects [2/4]

- (void) removeAllObjects

Empties the cache immediately.

◆ removeAllObjects [3/4]

- (void) removeAllObjects

Empties the cache immediately.

◆ removeAllObjects [4/4]

- (void) removeAllObjects

Empties the cache immediately.

◆ removeObjectForKey: [1/4]

- (void) removeObjectForKey: (id)  key

Removes the value of the specified key in the cache.

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

◆ removeObjectForKey: [2/4]

- (void) removeObjectForKey: (id)  key

Removes the value of the specified key in the cache.

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

◆ removeObjectForKey: [3/4]

- (void) removeObjectForKey: (id)  key

Removes the value of the specified key in the cache.

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

◆ removeObjectForKey: [4/4]

- (void) removeObjectForKey: (id)  key

Removes the value of the specified key in the cache.

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

◆ setObject:forKey: [1/4]

- (void) setObject: (nullable id)  object
forKey: (id)  key 

Sets the value of the specified key in the cache (0 cost).

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. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

◆ setObject:forKey: [2/4]

- (void) setObject: (nullable id)  object
forKey: (id)  key 

Sets the value of the specified key in the cache (0 cost).

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. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

◆ setObject:forKey: [3/4]

- (void) setObject: (nullable id)  object
forKey: (id)  key 

Sets the value of the specified key in the cache (0 cost).

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. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

◆ setObject:forKey: [4/4]

- (void) setObject: (nullable id)  object
forKey: (id)  key 

Sets the value of the specified key in the cache (0 cost).

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. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

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

- (void) setObject: (nullable id)  object
forKey: (id)  key
withCost: (NSUInteger)  cost 

Sets the value of the specified key in the cache, and associates the key-value pair with the specified cost.

Parameters
objectThe object to store in the cache. If nil, it calls removeObjectForKey.
keyThe key with which to associate the value. If nil, this method has no effect.
costThe cost with which to associate the key-value pair. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

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

- (void) setObject: (nullable id)  object
forKey: (id)  key
withCost: (NSUInteger)  cost 

Sets the value of the specified key in the cache, and associates the key-value pair with the specified cost.

Parameters
objectThe object to store in the cache. If nil, it calls removeObjectForKey.
keyThe key with which to associate the value. If nil, this method has no effect.
costThe cost with which to associate the key-value pair. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

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

- (void) setObject: (nullable id)  object
forKey: (id)  key
withCost: (NSUInteger)  cost 

Sets the value of the specified key in the cache, and associates the key-value pair with the specified cost.

Parameters
objectThe object to store in the cache. If nil, it calls removeObjectForKey.
keyThe key with which to associate the value. If nil, this method has no effect.
costThe cost with which to associate the key-value pair. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

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

- (void) setObject: (nullable id)  object
forKey: (id)  key
withCost: (NSUInteger)  cost 

Sets the value of the specified key in the cache, and associates the key-value pair with the specified cost.

Parameters
objectThe object to store in the cache. If nil, it calls removeObjectForKey.
keyThe key with which to associate the value. If nil, this method has no effect.
costThe cost with which to associate the key-value pair. @discussion Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

◆ trimToAge: [1/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache with LRU, until all expiry objects removed by the specified value.

Parameters
ageThe maximum age (in seconds) of objects.

◆ trimToAge: [2/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache with LRU, until all expiry objects removed by the specified value.

Parameters
ageThe maximum age (in seconds) of objects.

◆ trimToAge: [3/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache with LRU, until all expiry objects removed by the specified value.

Parameters
ageThe maximum age (in seconds) of objects.

◆ trimToAge: [4/4]

- (void) trimToAge: (NSTimeInterval)  age

Removes objects from the cache with LRU, until all expiry objects removed by the specified value.

Parameters
ageThe maximum age (in seconds) of objects.

◆ trimToCost: [1/4]

- (void) trimToCost: (NSUInteger)  cost

Removes objects from the cache with LRU, until the totalCost is or equal to the specified value.

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

◆ trimToCost: [2/4]

- (void) trimToCost: (NSUInteger)  cost

Removes objects from the cache with LRU, until the totalCost is or equal to the specified value.

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

◆ trimToCost: [3/4]

- (void) trimToCost: (NSUInteger)  cost

Removes objects from the cache with LRU, until the totalCost is or equal to the specified value.

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

◆ trimToCost: [4/4]

- (void) trimToCost: (NSUInteger)  cost

Removes objects from the cache with LRU, until the totalCost is or equal to the specified value.

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

◆ trimToCount: [1/4]

- (void) trimToCount: (NSUInteger)  count

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

@name Trim

Removes objects from the cache with LRU, until the totalCount is below or equal to the specified value.

Parameters
countThe total count allowed to remain after the cache has been trimmed.

◆ trimToCount: [2/4]

- (void) trimToCount: (NSUInteger)  count

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

@name Trim

Removes objects from the cache with LRU, until the totalCount is below or equal to the specified value.

Parameters
countThe total count allowed to remain after the cache has been trimmed.

◆ trimToCount: [3/4]

- (void) trimToCount: (NSUInteger)  count

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

@name Trim

Removes objects from the cache with LRU, until the totalCount is below or equal to the specified value.

Parameters
countThe total count allowed to remain after the cache has been trimmed.

◆ trimToCount: [4/4]

- (void) trimToCount: (NSUInteger)  count

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

@name Trim

Removes objects from the cache with LRU, until the totalCount is below or equal to the specified value.

Parameters
countThe total count allowed to remain after the cache has been trimmed.

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 object could be evicted later in backgound thread.

Definition at line 60 of file ThingEncryptMemoryCache.h.

◆ autoTrimInterval

- (NSTimeInterval) autoTrimInterval
readwriteatomic

The auto trim check time interval in seconds. Default is 5.0.

@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 68 of file ThingEncryptMemoryCache.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 backgound thread.

Definition at line 51 of file ThingEncryptMemoryCache.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 backgound thread.

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

@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 backgound thread.

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

@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 backgound thread.

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

@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 backgound thread.

Definition at line 42 of file ThingEncryptMemoryCache.h.

◆ didEnterBackgroundBlock

- (void(^ didEnterBackgroundBlock) (ThingEncryptMemoryCache *cache))
readwriteatomiccopy

A block to be executed when the app enter background. The default value is nil.

◆ didReceiveMemoryWarningBlock

- (void(^ didReceiveMemoryWarningBlock) (ThingEncryptMemoryCache *cache))
readwriteatomiccopy

A block to be executed when the app receives a memory warning. The default value is nil.

◆ 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 ThingEncryptMemoryCache.h.

◆ releaseAsynchronously

- (BOOL) releaseAsynchronously
readwriteatomic

If YES, the key-value pair will be released asynchronously to avoid blocking the access methods, otherwise it will be released in the access method (such as removeObjectForKey:). Default is YES.

Definition at line 108 of file ThingEncryptMemoryCache.h.

◆ releaseOnMainThread

- (BOOL) releaseOnMainThread
readwriteatomic

If YES, the key-value pair will be released on main thread, otherwise on background thread. Default is NO.

@discussion You may set this value to YES if the key-value object contains the instance which should be released in main thread (such as UIView/CALayer).

Definition at line 101 of file ThingEncryptMemoryCache.h.

◆ shouldRemoveAllObjectsOnMemoryWarning

- (BOOL) shouldRemoveAllObjectsOnMemoryWarning
readwriteatomic

If YES, the cache will remove all objects when the app receives a memory warning. The default value is YES.

Definition at line 74 of file ThingEncryptMemoryCache.h.

◆ shouldRemoveAllObjectsWhenEnteringBackground

- (BOOL) shouldRemoveAllObjectsWhenEnteringBackground
readwriteatomic

If YES, The cache will remove all objects when the app enter background. The default value is YES.

Definition at line 80 of file ThingEncryptMemoryCache.h.

◆ totalCost

- (NSUInteger) totalCost
readatomicassign

The total cost of objects in the cache (read-only).

Definition at line 27 of file ThingEncryptMemoryCache.h.

◆ totalCount

- (NSUInteger) totalCount
readatomicassign

The number of objects in the cache (read-only)

Definition at line 24 of file ThingEncryptMemoryCache.h.


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