[ Index ]
 

Code source de Claroline 188

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/claroline/inc/lib/pear/ -> Lite.php (sommaire)

Fast, light and safe Cache Class

Author: Fabien MARTY <fab@php.net>
Version: $Id: Lite.php,v 1.3 2006/12/05 14:26:45 moosh Exp $
Poids: 789 lignes (24 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 1 fichier
 claroline/inc/lib/pear/PEAR.php

Définit 1 class

Cache_Lite:: (21 méthodes):
  Cache_Lite()
  setOption()
  get()
  save()
  remove()
  clean()
  setToDebug()
  setLifeTime()
  saveMemoryCachingState()
  getMemoryCachingState()
  lastModified()
  raiseError()
  _setRefreshTime()
  _unlink()
  _cleanDir()
  _memoryCacheAdd()
  _setFileName()
  _read()
  _write()
  _writeAndControl()
  _hash()


Classe: Cache_Lite  - X-Ref

Cache_Lite($options = array(NULL)   X-Ref
Constructor

$options is an assoc. Available options are :
$options = array(
'cacheDir' => directory where to put the cache files (string),
'caching' => enable / disable caching (boolean),
'lifeTime' => cache lifetime in seconds (int),
'fileLocking' => enable / disable fileLocking (boolean),
'writeControl' => enable / disable write control (boolean),
'readControl' => enable / disable read control (boolean),
'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
'memoryCaching' => enable / disable memory caching (boolean),
'onlyMemoryCaching' => enable / disable only memory caching (boolean),
'memoryCachingLimit' => max nbr of records to store into memory caching (int),
'fileNameProtection' => enable / disable automatic file name protection (boolean),
'automaticSerialization' => enable / disable automatic serialization (boolean)
'automaticCleaningFactor' => distable / tune automatic cleaning process (int)
'hashedDirectoryLevel' => level of the hashed directory system (int)
'hashedDirectoryUmask' => umask for hashed directory structure (int)
);

param: array $options options

setOption($name, $value)   X-Ref
Generic way to set a Cache_Lite option

see Cache_Lite constructor for available options


get($id, $group = 'default', $doNotTestCacheValidity = false)   X-Ref
Test if a cache is available and (if yes) return it

param: string $id cache id
param: string $group name of the cache group
param: boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
return: string data of the cache (or false if no cache available)

save($data, $id = NULL, $group = 'default')   X-Ref
Save some data in a cache file

param: string $data data to put in cache (can be another type than strings if automaticSerialization is on)
param: string $id cache id
param: string $group name of the cache group
return: boolean true if no problem

remove($id, $group = 'default')   X-Ref
Remove a cache file

param: string $id cache id
param: string $group name of the cache group
return: boolean true if no problem

clean($group = false, $mode = 'ingroup')   X-Ref
Clean the cache

if no group is specified all cache files will be destroyed
else only cache files of the specified group will be destroyed

param: string $group name of the cache group
param: string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
return: boolean true if no problem

setToDebug()   X-Ref
Set to debug mode

When an error is found, the script will stop and the message will be displayed
(in debug mode only).


setLifeTime($newLifeTime)   X-Ref
Set a new life time

param: int $newLifeTime new life time (in seconds)

saveMemoryCachingState($id, $group = 'default')   X-Ref
Save the state of the caching memory array into a cache file cache

param: string $id cache id
param: string $group name of the cache group

getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)   X-Ref
Load the state of the caching memory array from a given cache file cache

param: string $id cache id
param: string $group name of the cache group
param: boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested

lastModified()   X-Ref
Return the cache last modification time

BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !

return: int last modification time

raiseError($msg, $code)   X-Ref
Trigger a PEAR error

To improve performances, the PEAR.php file is included dynamically.
The file is so included only when an error is triggered. So, in most
cases, the file isn't included and perfs are much better.

param: string $msg error message
param: int $code error code

_setRefreshTime()   X-Ref
Compute & set the refresh time


_unlink($file)   X-Ref
Remove a file

param: string $file complete file path and name
return: boolean true if no problem

_cleanDir($dir, $group = false, $mode = 'ingroup')   X-Ref
Recursive function for cleaning cache file in the given directory

param: string $dir directory complete path (with a trailing slash)
param: string $group name of the cache group
param: string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
return: boolean true if no problem

_memoryCacheAdd($data)   X-Ref
Add some date in the memory caching array

param: string $data data to cache

_setFileName($id, $group)   X-Ref
Make a file name (with path)

param: string $id cache id
param: string $group name of the group

_read()   X-Ref
Read the cache file and return the content

return: string content of the cache file

_write($data)   X-Ref
Write the given data in the cache file

param: string $data data to put in cache
return: boolean true if ok

_writeAndControl($data)   X-Ref
Write the given data in the cache file and control it just after to avoir corrupted cache entries

param: string $data data to put in cache
return: boolean true if the test is ok

_hash($data, $controlType)   X-Ref
Make a control key with the string containing datas

param: string $data data
param: string $controlType type of control 'md5', 'crc32' or 'strlen'
return: string control key



Généré le : Thu Nov 29 14:38:42 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics