Cache_Lite::remove() -- Efface un fichier de cache
Description
Efface un fichier de cache donnée (spécifié par son identifiant et son groupe).
Paramètres
- chaîne de caractères
$id
identifiant de cache
- chaîne de caractères
$group
nom du groupe de cache
Valeur retournée
Retourne TRUE si aucun problème ne survient.
Note
Cette fonction ne peut pas être appelée de façon statique.
Exemple
Exemple 36-1. Utilisation
<?php
require_once "Cache/Lite.php";
$options = array(
'cacheDir' => '/tmp/',
'lifeTime' => 7200,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$cache = new Cache_Lite($options);
$cache->remove('id_de_la_page');
if ($data = $cache->get('id_de_la_page')) {
// Cache présent !
// [IMPOSSIBLE !]
} else {
// Aucun cache valide n'a été trouvé (vous devez réaliser votre page et la sauvegarder)
$data = '<html><head><title>test</title></head><body><p>ceci est un test</p></body></html>';
$cache->save($data);
}
?>
|
|
Ceci est un exemple factice car le cache est détruit au début du script !
Donc, le premier cas de l'instruction if est impossible.
|
Cache_Lite::save (Previous)
|
(Next) Cache_Lite::clean
|
|
|
Download Documentation
|
Last updated: Sun, 28 Sep 2008 |
|
Do you think that something on this page is wrong? Please file a bug report or add a note.
|
| User Notes: |
Note by: n.sherlock@gmail.com
What leads you to believe that the first branch of the if statement is impossible? What if another script running concurrently has inserted a document with that ID in between the call to remove and call to get?
Note by: kemayo AT gmail
It's worth noting that if you saved a cache file with a group, you *have* to provide that group to remove it. (The group is part of the hash used to store it.)
|
|