Package DE_EPAGES::DataCache::API::Cache
This package provides an interface to cache data. To save a entry at cache use GetCache. The returned hash is a tied hash, which checks if the maximum count of elements is reached. Otherwise the tied-hash works like normal standard perl hash. To update the cache on other application servers use UpdateCache.
@EXPORT_OK |
Functions
GetCache
Gets a named cache. Creates a cache if not exists.
Syntax |
$NamedCache = GetCache($ConnectionKey, $CacheName); |
Example |
use DE_EPAGES::Database::API::Connection qw ( GetCurrentDBHandle ); my $dbi = GetCurrentDBHandle(); $NamedCache = GetCache($dbi->cacheKey, 'InfoYourObject'); |
Input |
|
Return |
|
UpdateCache
Updates a local cache and adds the items to touched cache to inform the message center about the changes. Deletes the complete cache $CacheName if $Key is not defined. Sets the cache value with key $Key to $hChanged if $hChanged is defined, otherwise deletes the key $Key from the cache.
Syntax |
UpdateCache($ConnectionKey, $CacheName); UpdateCache($ConnectionKey, $CacheName, $Key); UpdateCache($ConnectionKey, $CacheName, $Key, $hChanged); |
Input |
|
UpdateLocal
Deletes all local caches, dont inform other appserver (in case of transaction rollback).
Syntax |
UpdateLocal(); |
UpdateLocalCache
Updates a local cache, but unlike UpdateCache does not inform the message center about the changes. Deletes the complete cache $CacheName if $Key is not defined. Sets the cache value with key $Key to $hChanged if $hChanged is defined, otherwise deletes the key $Key from the cache.
Syntax |
UpdateLocalCache($ConnectionKey, $CacheName); UpdateLocalCache($ConnectionKey, $CacheName, $Key); UpdateLocalCache($ConnectionKey, $CacheName, $Key, $hChanged); |
Input |
|
totalBytes
Returns the current size of the cache. Caution: references and subroutines are not counted.
Syntax |
$Bytes = $Cache->totalBytes(); |
Example |
printf "%d MBytes in cache\n", GetRootCache()->totalBytes / 1048576; |
Return |
|