Php Data objects and structured storage

Source: Internet
Author: User
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/

?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.