<?php
include('./memcache.class.php');
$cache = Cache::getInstance();
//Checking if the the key exists
if($cache->exists("key"))
{
echo $cache->get("key");
} else {
$cache->set("key", "It's cached!", "900");
}
//Setting data in the memory
if(!cache->exists("hello"))
{
$cache->set("hello", "Hello! this is my cached data for 6 hours!", 60 * 60 * 6); //Interval: 60 * 60 * 6 (6 hours) or 21600 in seconds
echo $cache->get("hello");
}
//Replacing data for its key
if($cache->exists("test"))
{
$cache->update("key", "Here is my newly replaced data for the key (key) for one hour!", 60 * 60 * 1);
}
//Deleting data for a key
if($cache->exists("key"))
{
$cache->delete("key"); //We've now deleted the data for the key (key)!
}
//Flushing a projects memory block
$cache->flush(); //All the data for our prefix is now gone!
?>
|