Location: PHPKode > scripts > Files folder image SharedMemory > test_get.php
<?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
			
			//if you use database.you can del this
			$userinfo['id']=1;
			$userinfo['name']='test';
			$userinfo['hp']='100';
			$userinfo['hpmax']='100';
			$userinfo['ap']='10';
			$userinfo['dp']='10';

		}
	
		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_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');
$userinfo=$user_A->getData();
print_r($userinfo);


echo "<br /><br /><br />";
echo "<font color=red>change userinfo:</font><br />";
$userinfo['hp']='80';
$change=$userinfo;
$user_A->upData($change);
$userinfo=$user_A->getData();
print_r($userinfo);

echo "<br /><br /><br />";
echo "<font color=red>Synchronization userinfo:</font><br />";
$user_A->syncData();
$userinfo=$user_A->getData();
print_r($userinfo);


?>
Return current item: Files folder image SharedMemory