Packagegs.util.cache
Classpublic class Cache

The Cache class caches objects in memory.


Example
Caching an object:
 
  var cache:Cache=new Cache();
  var toCache:Object={myKey:"Hello",myOtherKey:"World"};
  cache.cacheObject("tocache",toCache);
  trace(cache.getCachedObject("tocache").myKey);
  



Public Methods
 MethodDefined by
  
Cache(purgeAllInterval:int = -1)
Constructor for Cache instances.
Cache
  
cacheObject(key:*, obj:int, expiresTimeout:Boolean = -1, overwrite:* = false):void
Cache an object in memory.
Cache
  
Clear the internal purge all interval.
Cache
  
dispose():void
Dispose of this Cache instance.
Cache
  
getCachedObject(key:*):*
Get's a cached Object.
Cache
  
isCached(key:*):Boolean
Test whether or not an object is cached.
Cache
  
purgeAll():void
Purges all cache.
Cache
  
purgeItem(key:*):void
Purge one item.
Cache
  
setPurgeAllInterval(interval:Number):void
Set and or reset the purge all interval.
Cache
Constructor detail
Cache()constructor
public function Cache(purgeAllInterval:int = -1)

Constructor for Cache instances.

Parameters
purgeAllInterval:int (default = -1) — An interval that purges all items in the cache every time the interval is called.
Method detail
cacheObject()method
public function cacheObject(key:*, obj:int, expiresTimeout:Boolean = -1, overwrite:* = false):void

Cache an object in memory.

Parameters
key:* — The key to store the object by.
 
obj:int — The object data.
 
expiresTimeout:Boolean (default = -1) — The timeout to expire this item after.
 
overwrite:* (default = false) — Overwrite the previously cached item.
clearPurgeAllInterval()method 
public function clearPurgeAllInterval():void

Clear the internal purge all interval.

dispose()method 
public function dispose():void

Dispose of this Cache instance. The difference between this and purgeAll is that dispose will render this cache instance not usable again. But purgeAll simply resets this cache, and is still usable afterwords.

getCachedObject()method 
public function getCachedObject(key:*):*

Get's a cached Object.

Parameters
key:* — The key of the object that is cached.

Returns
*
isCached()method 
public function isCached(key:*):Boolean

Test whether or not an object is cached.

Parameters
key:* — The key of the object that is cached.

Returns
Boolean
purgeAll()method 
public function purgeAll():void

Purges all cache.

purgeItem()method 
public function purgeItem(key:*):void

Purge one item.

Parameters
key:* — The key for the object that is stored.
setPurgeAllInterval()method 
public function setPurgeAllInterval(interval:Number):void

Set and or reset the purge all interval.

Parameters
interval:Number