Class: CacheManager

@aofl/cache-manager~ CacheManager

Provides a unified class for storing objects in Storage-like Objects. You can choose from localStorage, sessionStorage and memoryStorage.

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
Source:

Members


expire :Number

Type:
  • Number
Source:

namespace :String

Type:
  • String
Source:

<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
Source:

storageType :cacheTypeEnumerate

Type:
  • cacheTypeEnumerate
Source:

Methods


clear()

The clear() method of the CacheManager interface, when invoked, clears all stored keys
Source:

destruct()

The destruct() method of the CacheManager interface, when invoked, resets all instance variables and clears expire interval.
Source:

getCollection()

The getItem() method of the CacheManager interface, wen invoked, will return the key/value pairs that that instance of CacheManager tracks.
Source:
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
Source:
Returns:
Type
*

getNamespaceKey(key)

Returns the serialized key based on namespace
Parameters:
Name Type Description
key String
Source:
Returns:
Type
String

getStoredKeys()

Returns keys controlled by the instance of CacheManager
Source:
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.
Source:
Returns:
Type
Boolean

removeExpired()

The removeExpired() method of the CacheManager interface, when invoked, Removes all expired keys.
Source:

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
Source:

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.
Source: