Storage of data objects and structures in PHP
1. Use serialization and deserialization functions, and then save the serialized results $result to a file or database for persistent storage
$result = serialize ($data);
?
$data = Unserialize ($result)?
?
2. Using the distributed Memory Object cache system memcached
2.1 Installing the Memcached client stores data in the client's memory
Version Win32 memcached?http://code.jellycan.com/memcached/
Can be installed as a service
?
memcached-d Install
memcached-d start
?
2.2 Installing the PHP extension
Download Http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip
Edit PHP.ini Extension=php_memcache.dll
Example code:
?
?
Connect (' localhost ', 11211) or Die ("Could not Connect"), $version = $memcache->getversion (); echo "Server s version:". $version. "
\ n "; $tmp _object = new StdClass; $tmp _object->str_attr = ' test '; $tmp _object->int_attr = 123; $memcache->set (' Key ', $tmp _object, False, Ten) or Die ("Failed-to-save data at the server"); echo "Store data in the" cache (data would expire in seconds)
\ n "; $get _result = $memcache->get (' key '); echo" Data from the cache:
\ n "; Var_dump ($get _result);? >
? Reference URL: http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/
?