Cache_Lite::remove() – Remove a cache file


require_once 'Cache/Lite.php';

boolean Cache_Lite::remove ( string $id , string $group = 'default' )


remove the given cache file (specified with its id and group)


string $id

cache id

string $group

name of the cache group

Return value

returns true if no problem


This function can not be called statically.



require_once "Cache/Lite.php";

$options = array(
'cacheDir' => '/tmp/',
'lifeTime' => 7200,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
$cache = new Cache_Lite($options);


if (
$data $cache->get('id_of_the_page')) {

// Cache hit !
    // [IMPOSSIBLE !]

} else { 
// No valid cache found (you have to make and save the page)
$data '<html><head><title>test</title></head><body><p>this is a test</p></body></html>';


This is a dummy example because the cache is destroyed at the beginning of the script ! So the first case of the if statement is impossible.

Save some data in a cache file (Previous) Clean the cache (Next)
Last updated: Thu, 26 Nov 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by:
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.)