PHP Data Objects, constructed storage

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

?

  • 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.