[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Cache/ -> Container.php (sommaire)

(pas de description)

Poids: 455 lignes (14 kb)
Inclus ou requis: 7 fois
Référencé: 0 fois
Nécessite: 1 fichier
 Cache/Error.php

Définit 1 class

Cache_Container:: (16 méthodes):
  load()
  getUserdata()
  isExpired()
  isCached()
  fetch()
  save()
  remove()
  flush()
  idExists()
  garbageCollection()
  preload()
  flushPreload()
  setOptions()
  encode()
  decode()
  getExpiresAbsolute()


Classe: Cache_Container  - X-Ref

Common base class of all cache storage container.

To speed up things we do a preload you should know about, otherwise it might
play you a trick. The Cache controller classes (Cache/Cache, Cache/Output, ...)
usually do something like is (isCached($id) && !isExpired($id)) return $container->load($id).
if you implement isCached(), isExpired() and load() straight ahead, each of this
functions will result in a storage medium (db, file,...) access. This generates too much load.
Now, a simple speculative preload should saves time in most cases. Whenever
one of the mentioned methods is invoked we preload the cached dataset into class variables.
That means that we have only one storage medium access for the sequence
(isCached($id) && !isExpired($id)) return $container->load($id).
The bad thing is that the preloaded data might be outdated meanwhile, which is
unlikely but for you power users, be warned. If you do not want the preload
you should switch it off by setting the class variable $preload to false. Anyway, this is
not recommended!

load($id, $group)   X-Ref
Loads a dataset from the cache.

param: string  dataset ID
param: string  cache group
return: mixed   dataset value or NULL on failure

getUserdata($id, $group)   X-Ref
Returns the userdata field of a cached data set.

param: string  dataset ID
param: string  cache group
return: string  userdata

isExpired($id, $group, $max_age)   X-Ref
Checks if a dataset is expired.

param: string  dataset ID
param: string  cache group
param: integer maximum age timestamp
return: boolean

isCached($id, $group)   X-Ref
Checks if a dataset is cached.

param: string  dataset ID
param: string  cache group
return: boolean

fetch($id, $group)   X-Ref
Fetches a dataset from the storage medium.

param: string  dataset ID
param: string  cache group
return: array   format: [expire date, cached data, user data]

save($id, $data, $expire, $group, $userdata)   X-Ref
Stores a dataset.

param: string  dataset ID
param: mixed   data to store
param: mixed   userdefined expire date
param: string  cache group
param: string  additional userdefined data
return: boolean

remove($id, $group)   X-Ref
Removes a dataset.

param: string  dataset ID
param: string  cache group
return: boolean  

flush($group)   X-Ref
Flushes the cache - removes all caches datasets from the cache.

param: string      If a cache group is given only the group will be flushed
return: integer     Number of removed datasets, -1 on failure

idExists($id, $group)   X-Ref
Checks if a dataset exists.

param: string  dataset ID
param: string  cache group
return: boolean

garbageCollection()   X-Ref
Starts the garbage collection.


preload($id, $group)   X-Ref
Does a speculative preload of a dataset

param: string  dataset ID
param: string  cache group
return: boolean

flushPreload($id = '', $group = 'default')   X-Ref
Flushes the internal preload buffer.

save(), remove() and flush() must call this method
to preevent differences between the preloaded values and
the real cache contents.

param: string  dataset ID, if left out the preloaded values will be flushed.
param: string  cache group

setOptions($requested, $allowed)   X-Ref
Imports the requested datafields as object variables if allowed

param: array   List of fields to be imported as object variables
param: array   List of allowed datafields

encode($data)   X-Ref
Encodes the data for the storage container.


decode($data)   X-Ref
Decodes the data from the storage container.


getExpiresAbsolute($expires)   X-Ref
Translates human readable/relative times in unixtime

param: mixed   can be in the following formats:
return: integer unix timestamp



Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7