CacheService  (since version 2.0)
Type Service
Constants
integer DECORATOR = 4
the decorator flag for selecting as cache handler.
integer FILESYSTEM = 2
The filesystem flag for selecting as cache handler.
integer MEMCACHE = 1
The memcache flag for selecting as cache handler.
string PROFILE_PREFIX = " CS. "
The profile prefix which is added to the cache entry of any cache handler.
Description
The cache service is used to cache any type of data. It can be used with up to three different cache handler at once.
The handler can be selected as one or combined
The laoding of the stored data has for each cache handler an different priority. At first it will be loaded (if available) from the own assigned decorator, than from the memcache(if available) and at last from the filesystem. If one has an cache output, the loaded data will be retrieved. The save routine is different. It stores always the output into all assigned cache handler.

You can currently use the filesystem, memcache or you own class as decorator to handle the cache action (Save, Load, Remove).

The cache service uses the profile service to store the created profiles and accesing any profile related data.
Examples
<?php

//create Cache profile
CacheService::CreateProfile('CacheSample');

// use the current created cache profile
CacheService::Begin('CacheSample');

// set the lifetime to 15 seconds (default 24h)
CacheService::SetCacheLifetime(15);

//set cache handler to filesystem based (default)
CacheService::SetCacheHandler(CacheService::FILESYSTEM);

// save data with a specific key
CacheService::Save('test', array(1,2,3));

// release current cache profile 
CacheService::End();

?>

Last change 10/16/2009




Administration