<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
session_cache_limiter('no-cache');
/*
*example class
*/
class UserInfo
{
var $userinfo;
function getUserInfo($id)
{
if ($id==0 or id=='')
{
return '';
}
$userinfo = eaccelerator_get('UserInfo_getUserInfo_'.$id);
if (!$userinfo)
{
//you database code like: select * from user where id=$id
//del test
}
return $userinfo;
}
function getUserInfo_updata($id,$data)
{
if ($id<>0 and $id<>'')
{
//check db
//if it have this id then updata ,else insert
//like this: updata user set hp=$data['hp'] where id = $id
//here just easy example
//if you use database.you can del this
echo "<br /><br />call UserInfo::getUserInfo_sync_updata()<br />";
echo "<br /><br />id:".$id."<br />";
echo "data:";
print_r($data);
echo "<br />";
}
}
function getUserInfo_del($id)
{
if ($id<>0 and $id<>'')
{
//check db
//if it have this id then updata ,else insert
//like this:delete user where id = $id
//here just easy example
//if you use database.you can del this
echo "<br />call UserInfo::getUserInfo_del()<br />";
echo "<br /><br />id:".$id."<br />";
}
}
}
require_once 'SharedMemory.class.php';
/*
*example how to use
*
*You can set regular implementation of the syncData();
*/
echo "<font color=red>get userinfo:</font><br />";
$user_A=new SharedMemory('UserInfo','GetUserInfo','1');
$user_A->delData();
$userinfo=$user_A->getData();
print_r($userinfo);
echo "<br /><br /><br />";
?>
|