NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
An in-memory cache for storing objects with expiration support.
The Nimbus in-memory object cache allows you to store objects in memory with an expiration date attached. Objects with expiration dates drop out of the cache when they have expired.
Tasks | |
Creating an In-Memory Cache | |
(id) | - initWithCapacity: |
Querying an In-Memory Cache | |
(NSUInteger) | - count |
Storing Objects in the Cache | |
(void) | - storeObject:withName: |
(void) | - storeObject:withName:expiresAfter: |
Removing Objects from the Cache | |
(void) | - removeObjectWithName: |
(void) | - removeAllObjectsWithPrefix: |
(void) | - removeAllObjects |
Accessing Objects in the Cache | |
(id) | - objectWithName: |
(BOOL) | - containsObjectWithName: |
(NSDate *) | - dateOfLastAccessWithName: |
(NSString *) | - nameOfLeastRecentlyUsedObject |
(NSString *) | - nameOfMostRecentlyUsedObject |
Reducing Memory Usage Explicitly | |
(void) | - reduceMemoryUsage |
Subclassing | |
The following methods are provided to aid in subclassing and are not meant to be used externally. | |
(BOOL) | - shouldSetObject:withName:previousObject: |
(void) | - didSetObject:withName: |
(void) | - willRemoveObject:withName: |
(BOOL) | - willSetObject:withName:previousObject: |
Initializes a newly allocated cache with the given capacity.
Returns the number of objects currently in the cache.
Stores an object in the cache.
The object will be stored without an expiration date. The object will stay in the cache until it's bumped out due to the cache's memory limit.
object | The object being stored in the cache. |
name | The name used as a key to store this object. |
Stores an object in the cache with an expiration date.
If an object is stored with an expiration date that has already passed then the object will not be stored in the cache and any existing object will be removed. The rationale behind this is that the object would be removed from the cache the next time it was accessed anyway.
object | The object being stored in the cache. |
name | The name used as a key to store this object. |
expirationDate | A date after which this object is no longer valid in the cache. |
Removes an object from the cache with the given name.
name | The name used as a key to store this object. |
Removes all objects from the cache with a given prefix.
This method requires a scan of the cache entries.
prefix | Any object name that has this prefix will be removed from the cache. |
Removes all objects from the cache, regardless of expiration dates.
This will completely clear out the cache and all objects in the cache will be released.
Retrieves an object from the cache.
If the object has expired then the object will be removed from the cache and nil will be returned.
Returns a Boolean value that indicates whether an object with the given name is present in the cache.
Does not update the access time of the object.
If the object has expired then the object will be removed from the cache and NO will be returned.
Returns the date that the object with the given name was last accessed.
Does not update the access time of the object.
If the object has expired then the object will be removed from the cache and nil will be returned.
Retrieve the name of the object that was least recently used.
This will not update the access time of the object.
If the cache is empty, returns nil.
Retrieve the key with the most fresh access.
This will not update the access time of the object.
If the cache is empty, returns nil.
Removes all expired objects from the cache.
Subclasses may add additional functionality to this implementation. Subclasses should call super in order to prune expired objects.
This will be called when UIApplicationDidReceiveMemoryWarningNotification
is posted.
An object is about to be stored in the cache.
object | The object that is about to be stored in the cache. |
name | The cache name for the object. |
previousObject | The object previously stored in the cache. This may be the same as object. |
An object has been stored in the cache.
object | The object that was stored in the cache. |
name | The cache name for the object. |
An object is about to be removed from the cache.
object | The object about to removed from the cache. |
name | The cache name for the object about to be removed. |
This method is deprecated.
Please use shouldSetObject:withName:previousObject: instead.