Storage of php Data objects and structures 1. use serialization and deserialization functions ,? Then save the serialized result $ result to a file or database for persistent storage $ result = serialize ($ data );? $ Data = unserialize ($ resul php data object and structure storage
1. use serialization and deserialization functions ,? Then save the serialized result $ result to a file or database for persistent storage.
$ Result = serialize ($ data );
?
$ Data = unserialize ($ result )?
?
2. use the distributed memory object cache system memcached
2.1 install the memcached client to store data in the memory of the client
Memcached for win32? Http://code.jellycan.com/memcached/
Can be installed as a Service
?
Memcached-d install
Memcached-d start
?
2.2 install php extension
Download? Http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip
Edit php. ini extension = php_memcache.dll
Sample 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, 10) or die ("Failed to save data at the server");echo "Store data in the cache (data will expire in 10 seconds)
\n";$get_result = $memcache->get('key');echo "Data from the cache:
\n";var_dump($get_result);?>
? Reference: http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/
?