phpBB

Development Wiki

Cache

From phpBB Development Wiki

Revision as of 00:38, 6 June 2009 by Toonarmy (Talk | contribs)

The cache system provides an API for caching frequently used data, it provides an interface for user code to cache data and an interface for the DBAL to cache query results.

Interface

Name Description Parameters Signature
Name Description
Data manipulation
acm::get() Retrieve a cached data object, returns false on failure. $var_name Variable name
function get($var_name)
acm::put() Store a data object in the cache with an optional time-to-live. $var_name Variable name
function put($var_name$var$ttl)
$var Data to store
$ttl Time-to-live (optional)
acm::destroy() Remove a stored object from the cache. $var_name Variable name
function destroy($var_name)
Utility methods
acm::tidy() Perform garbage collection on the cache, removing expired data objects. none
function tidy()
acm::purge() Empty the cache of all data. none
function purge()
acm::save() Commit in memory data to the cache back end. none
function save()
DBAL Interface
acm::sql_load() $query Query to load from cache
function sql_load($query)
acm::sql_save() $query Query to load from cache
function sql_save($query, &$query_result$ttl)
$query_result Result
$ttl Time-to-live
acm::sql_exists() $query_id ID
function sql_exists($query_id)
acm::sql_fetchrow() $query_id ID
function sql_fetchrow($query_id)
acm::sql_fetchfield() $query_id ID
function sql_fetchfield($query_id$field)
$field
acm::sql_rowseek() $rownum Row number to seek to
function sql_rowseek($rownum$query_id)
$query_id ID

Modules

Module Description Version File
File Utilises disk drive for data storage >= 2.1 includes/acm/acm_file.php
XCache [1] Storage of data in shared memory >= 3.0.6 includes/acm/acm_xcache.php
APC [2] Storage of data in shared memory >= 3.0.6 includes/acm/acm_apc.php
eAccelerator [3] Storage of data in shared memory >= 3.0.6 includes/acm/acm_eaccelerator.php
Memcache [4] Uses a memcached instance to store data >= 3.0.6 includes/acm/acm_memcache.php

File

As of 3.0.6-dev the file cache module uses a new improved format for its cache files.

Where:

  • expiration := expiration timestamp
  • query := SQL query
  • bytes := number of bytes in data (except global data includes the length of var)
  • var := Variable name
  • data := Cached data


SQL queries:

<?php exit; ?>
(expiration)
(query)
(bytes)
(data)


Normal data:

<?php exit; ?>
(expiration)
(bytes)
(data)


Global data:

<?php exit; ?>
(expiration)
(bytes)
(var)
(data)
(expiration-n)
(bytes-n)
(var-n)
(data-n)
...


This article is a stub. You can help in improving Olympus Documentation by expanding it.