Properties

$options

$options : array

Options disponibles

====> (string) stockage_chemin : Chemin vers le dossier devant contenir l'arborescence du cache.

=====> (boolean) fichier_verrou :

  • Active / Désactive le verrouillage des fichiers
  • Peut éviter la corruption du cache dans de mauvaises circonstances, mais cela ne fonctionne pas sur des serveur multithread et sur les systèmes de fichiers NFS par exemple.

=====> (boolean) controle_lecture :

  • Activer / désactiver le contrôle de lecture
  • S'il est activé, une clé de contrôle est ajoutée dans le fichier de cache et cette clé est comparée avec celle calculée après la lecture.

=====> (string) controle_lecture_type : Type de contrôle de lecture (seulement si le contrôle de lecture est activé). Les valeurs disponibles sont:

  • «md5» pour un contrôle md5 (le meilleur mais le plus lent)
  • «crc32» pour un contrôle de hachage crc32 (un peu moins sécurisé, mais plus rapide, un meilleur choix)
  • «adler32» pour un contrôle de hachage adler32 (excellent choix aussi, plus rapide que crc32)
  • «strlen» pour un test de longueur uniquement (le plus rapide)

=====> (int) dossier_niveau :

  • Permet de réglez le nombre de niveau de sous-dossier que contiendra l'arborescence des dossiers du cache. 0 signifie "pas de sous-dossier pour le cache", 1 signifie "un niveau de sous-dossier", 2 signifie "deux niveaux" ... Cette option peut accélérer le cache seulement lorsque vous avez plusieurs centaines de fichiers de cache. Seuls des tests spécifiques peuvent vous aider à choisir la meilleure valeur possible pour vous. 1 ou 2 peut être est un bon début.

=====> (int) dossier_umask :

  • Umask pour les sous-dossiers de l'arborescence du cache.

=====> (string) fichier_prefixe :

  • préfixe pour les fichiers du cache
  • ATTENTION : faite vraiment attention avec cette option, car une valeur trop générique dans le dossier cache du système (comme /tmp) peut provoquer des catastrophes lors du nettoyage du cache.

=====> (int) fichier_umask :

  • Umask pour les fichiers de cache

=====> (int) metadonnees_max_taille :

  • taille maximum pour le tableau de métadonnées du cache (ne changer pas cette valeur sauf si vous savez ce que vous faite)

Type

array — options disponibles

$metadonnees

$metadonnees : array

Array of metadatas (each item is an associative array)

Type

array

$Cache

$Cache

Methods

__construct()

__construct(array $options, \Cache $cache) : void

Constructor

Parameters

array $options

associative array of options

\Cache $cache

Throws

\Zend_Cache_Exception

setEmplacement()

setEmplacement( $emplacement)

Parameters

$emplacement

charger()

charger(string $id,  $ne_pas_tester_validiter_du_cache) : string|false

Test if a cache is available for the given id and (if yes) return it (false else)

Parameters

string $id

cache id

$ne_pas_tester_validiter_du_cache

Returns

string|false —

cached datas

tester()

tester(string $id) : mixed

Teste si un enregistrement en cache est disponible ou pas (pour l'id passé en paramètre).

Parameters

string $id

identifiant de cache.

Returns

mixed —

false (le cache n'est pas disponible) ou timestamp (int) "de dernière modification" de l'enregistrement en cache

sauver()

sauver( $donnees, string $id, array $tags,  $duree_vie_specifique) : boolean

Save some string datas into a cache record

Note : $data is always "string" (serialization is done by the core not by the backend)

Parameters

$donnees
string $id

Cache id

array $tags

Array of strings, the cache record will be tagged by each string entry

$duree_vie_specifique

Returns

boolean —

true if no problem

supprimer()

supprimer(string $id) : boolean

Remove a cache record

Parameters

string $id

cache id

Returns

boolean —

true if no problem

nettoyer()

nettoyer(string $mode,  $tags) : boolean

Clean some cache records

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => remove too old cache entries ($tags is not used) 'matchingTag' => remove cache entries matching all given tags

             ($tags can be an array of strings or a single string)

'notMatchingTag' => remove cache entries not matching one of the given tags

             ($tags can be an array of strings or a single string)

'matchingAnyTag' => remove cache entries matching any given tags

             ($tags can be an array of strings or a single string)

Parameters

string $mode

clean mode

$tags

Returns

boolean —

true if no problem

getIds()

getIds() : array

Return an array of stored cache ids

Returns

array —

array of stored cache ids (string)

getTags()

getTags() : array

Return an array of stored tags

Returns

array —

array of stored tags (string)

getIdsAvecLesTags()

getIdsAvecLesTags(array $tags) : array

Return an array of stored cache ids which match given tags

In case of multiple tags, a logical AND is made between tags

Parameters

array $tags

array of tags

Returns

array —

array of matching cache ids (string)

getIdsSansLesTags()

getIdsSansLesTags(array $tags) : array

Return an array of stored cache ids which don't match given tags

In case of multiple tags, a logical OR is made between tags

Parameters

array $tags

array of tags

Returns

array —

array of not matching cache ids (string)

getIdsAvecUnTag()

getIdsAvecUnTag(array $tags) : array

Return an array of stored cache ids which match any given tags

In case of multiple tags, a logical AND is made between tags

Parameters

array $tags

array of tags

Returns

array —

array of any matching cache ids (string)

getPourcentageRemplissage()

getPourcentageRemplissage() : int

Return the filling percentage of the backend storage

Throws

\Zend_Cache_Exception

Returns

int —

integer between 0 and 100

getMetadonnees()

getMetadonnees(string $id) : array

Return an array of metadatas for the given cache id

The array must include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time

Parameters

string $id

cache id

Returns

array —

array of metadatas (false if the cache id is not found)

ajouterSupplementDureeDeVie()

ajouterSupplementDureeDeVie(string $id,  $supplement_duree_de_vie) : boolean

Give (if possible) an extra lifetime to the given cache id

Parameters

string $id

cache id

$supplement_duree_de_vie

Returns

boolean —

true if ok

getMetadonneesFichier()

getMetadonneesFichier(string $id) : array|false

Get a metadatas record

Parameters

string $id

Cache id

Returns

array|false —

Associative array of metadatas

setMetadonnees()

setMetadonnees(string $id,  $metadonnees,  $sauvegarde) : boolean

Set a metadatas record

Parameters

string $id

Cache id

$metadonnees
$sauvegarde

Returns

boolean —

True if no problem

supprimerMetadonnees()

supprimerMetadonnees(string $id) : boolean

Drop a metadata record

Parameters

string $id

Cache id

Returns

boolean —

True if no problem

nettoyerMetadonnees()

nettoyerMetadonnees() : void

Clear the metadatas array

chargerMetadonnees()

chargerMetadonnees(string $id) : array|false

Load metadatas from disk

Parameters

string $id

Cache id

Returns

array|false —

Metadatas associative array

sauverMetadonnees()

sauverMetadonnees(string $id,  $metadonnees) : boolean

Save metadatas to disk

Parameters

string $id

Cache id

$metadonnees

Returns

boolean —

True if no problem

getNomFichierMeta()

getNomFichierMeta(string $id) : string

Make and return a file name (with path) for metadatas

Parameters

string $id

Cache id

Returns

string —

Metadatas file name (with path)

etreFichierMeta()

etreFichierMeta( $fichier_nom) : boolean

Check if the given filename is a metadatas one

Parameters

$fichier_nom

Returns

boolean —

True if it's a metadatas one

supprimerFichier()

supprimerFichier( $fichier) : boolean

Remove a file

If we can't remove the file (because of locks or any problem), we will touch the file to invalidate it

Parameters

$fichier

Returns

boolean —

True if ok

nettoyerFichiers()

nettoyerFichiers( $dossier, string $mode, array $tags) : boolean

Clean some cache records (protected method used for recursive stuff)

Available modes are : Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags

                                       ($tags can be an array of strings or a single string)

Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}

                                       ($tags can be an array of strings or a single string)

Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags

                                       ($tags can be an array of strings or a single string)

Parameters

$dossier
string $mode

Clean mode

array $tags

Array of tags

Throws

\Zend_Cache_Exception

Returns

boolean —

True if no problem

analyserCache()

analyserCache( $dossier,  $mode,  $tags)

Parameters

$dossier
$mode
$tags

genererCleSecu()

genererCleSecu( $donnees,  $type_de_controle) : string

Make a control key with the string containing datas

Parameters

$donnees
$type_de_controle

Throws

\Zend_Cache_Exception

Returns

string —

Control key

transformaterIdEnNomFichier()

transformaterIdEnNomFichier(string $id) : string

Transform a cache id into a file name and return it

Parameters

string $id

Cache id

Returns

string —

File name

getFichierNom()

getFichierNom(string $id) : string

Make and return a file name (with path)

Parameters

string $id

Cache id

Returns

string —

File name (with path)

getChemin()

getChemin(string $id, boolean $decoupage) : string

Return the complete directory path of a filename (including hashedDirectoryStructure)

Parameters

string $id

Cache id

boolean $decoupage

if true, returns array of directory parts instead of single string

Returns

string —

Complete directory path

lancerMkdirEtChmodRecursif()

lancerMkdirEtChmodRecursif(string $id) : boolean

Make the directory strucuture for the given id

Parameters

string $id

cache id

Returns

boolean —

true

testerExistenceCache()

testerExistenceCache(string $id,  $ne_pas_tester_validiter_du_cache) : boolean|mixed

Test if the given cache id is available (and still valid as a cache record)

Parameters

string $id

Cache id

$ne_pas_tester_validiter_du_cache

Returns

boolean|mixed —

false (a cache is not available) or "last modified" timestamp (int) of the available cache record

getContenuFichier()

getContenuFichier( $fichier) : string

Return the file content of the given file

Parameters

$fichier

Returns

string —

File content (or false if problem)

setContenuFichier()

setContenuFichier( $fichier,  $chaine) : boolean

Put the given string into the given file

Parameters

$fichier
$chaine

Returns

boolean —

true if no problem

transformerNomFichierEnId()

transformerNomFichierEnId( $nom_de_fichier) : string

Transform a file name into cache id and return it

Parameters

$nom_de_fichier

Returns

string —

Cache id

initialiserOptionsParConfig()

initialiserOptionsParConfig()

setOptions()

setOptions( $options)

Parameters

$options