Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Eugene Panin  >  ObjectCache2  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage example
Class: ObjectCache2
Stores objects in different types of chache
Author: By
Last change: Documentaion changed
Date: 2003-02-18 14:43
Size: 865 bytes
 

Contents

Class file image Download
<?php
// @author Eugene Panin, <varenich@yahoo.com>
// Please visit our home page at http://www.tortuga.pp.ru

require 'ObjectCache/ObjectCache.php';

// Allocating object
$ttt 987492138491287349;

// Shared memory block size
$size 500;

// Getting object cache
$oc =& ObjectCache::factory('shmop',1,array('size'=>$size));
// Put object into cache
$oc->add('test',&$ttt);
// Removing cache
unset($oc);

// Imaging that it's another script in another time :-)
$oc1 =& ObjectCache::factory('shmop',1,array('size'=>$size));
$res =& $oc1->find("test");
// Wow! Our object is here!
var_dump($res);
// You still not sure that object was in cache? Then remove it
$oc1->remove("test");
unset(
$oc1);

$oc2 =& ObjectCache::factory('shmop',1,array('size'=>$size));
$res2 =& $oc2->find("test");
// You see, it's empty now
var_dump($res2);
?>