new CacheManager(namespace [, storageType] [, expire])
Creates an instance of CacheManager.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
namespace |
* | used to group keys controlled by each instance since the starage objects are shared | ||
storageType |
* |
<optional> |
cacheTypeEnumerate.MEMORY | memory, local or session |
expire |
number |
<optional> |
3600000 | cache expiration in ms |
Members
-
expire :Number
-
Type:
- Number
-
namespace :String
-
Type:
- String
-
<readonly> size :Number
-
The size read-only property of the Storage interface returns an integer representing the number of data items stored in the Storage object.
Type:
- Number
-
storageType :cacheTypeEnumerate
-
Type:
- cacheTypeEnumerate
Methods
-
clear()
-
The clear() method of the CacheManager interface, when invoked, clears all stored keys
-
destruct()
-
The destruct() method of the CacheManager interface, when invoked, resets all instance variables and clears expire interval.
-
getCollection()
-
The getItem() method of the CacheManager interface, wen invoked, will return the key/value pairs that that instance of CacheManager tracks.
Returns:
- Type
- Object
-
getItem(key)
-
The getItem() method of the CacheManager interface, when passed a key name, will return that key's value or null if the key does not exist.
Parameters:
Name Type Description key
String The name of the key you want to retrieve the value of Returns:
- Type
- *
-
getNamespaceKey(key)
-
Returns the serialized key based on namespace
Parameters:
Name Type Description key
String Returns:
- Type
- String
-
getStoredKeys()
-
Returns keys controlled by the instance of CacheManager
Returns:
- Type
- Array
-
isExpired(key)
-
The isExpired() method of the CacheManager interface, when invoked, checks if the given key is expired.
Parameters:
Name Type Description key
String The name of the key you want to check if is expired. Returns:
- Type
- Boolean
-
removeExpired()
-
The removeExpired() method of the CacheManager interface, when invoked, Removes all expired keys.
-
removeItem(key)
-
The removeItem() method of the CacheManager interface, when passed a key name, will remove that key from the storage if it exists. If there is no item associated with the given key, this method will do nothing.
Parameters:
Name Type Description key
String The name of the key you want to remove -
setItem(key, value)
-
The setItem() method of the CacheManager interface, when passed a key name and value, will add that key to the storage, or update that key's value if it already exists
Parameters:
Name Type Description key
String A String containing the name of the key you want to create/update. value
* The value you want to give the key you are creating/updating.