ePages 7.27.0 - DE_EPAGES/Object/API/PageCache.pm

Package DE_EPAGES::Object::API::PageCache

Interface for page cache handling.

Functions

clearObjectCache
clearSiteCache
compute
new

clearObjectCache

Deletes all pages of a given object from the cache.

Syntax
$PageCache->clearObjectCache($Object);
Input
$Object (DE_EPAGES::Object::API::Object::Object)
object

clearSiteCache

Deletes all pages of a given site from the cache.

Syntax
$PageCache->clearSiteCache;

compute

Gets a page from the cache or computes a new page and stores it in the cache. Returns $Content = undef if the content has not been modified since $IfModifiedSince.

Syntax
($Content, LastModified) = $PageCache->compute($Object, $CacheKeyPart, $IfModifiedSince, $Sub);
Example
($Content, LastModified) = $PageCache->compute($Object, 'View_en_GB',
    time() - 100, sub { return "Today is: ".scalar(localtime), 1 };
);
Input
$Object (DE_EPAGES::Object::API::Object::Object)
object
$CacheKeyPart (string)
cache key unique for $Object
$IfModifiedSince (int)
(optional) epoch value of last modification
from the HTTP header If-Modified-Since
$Sub (ref.code)
function to compute the page content if the page is not already
cached. This function returns 2 values: $Content and $IsCacheable.
If $IsCacheable is true, the content is stored in the cache
Return
$Content (string)
page content or undef if the page has not been modified since
the last request (given by $IfModifiedSince)
$LastModified (int)
time of last modification, i.e. when the content has been
stored into the cache (given as epoch value)

new

Creates a PageCache object for a Site.

Syntax
$PageCache = DE_EPAGES::Object::API::PageCache->new( %Options );
Example
$PageCache = DE_EPAGES::Object::API::PageCache->new( Site => $Site );
Input
%Options
options
  • Site - Site object - object
Return
$PageCache (DE_EPAGES::Object::API::PageCache)
PageCache object