Redis Cache PHP Data

Source: Internet
Author: User
Tags config memcached redis install redis

Redis:key-value Storage System. Like memcached, it supports a relatively larger number of stored value types, including string (string), list (linked list), set (set), and Zset (ordered set). These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic. On this basis, Redis supports a variety of different ways of ordering. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification operation to the appended record file, and on this basis, it realizes the Master-slave (master-slave) synchronization.

1. Install Redis

#wget http://redis.googlecode.com/files/redis-2.4.11.tar.gz
#tar Xzf redis-2.4.11.tar.gz
#cd redis-2.4.11

#make
#redis -2.4.11> Redis-server
Open a window again
#cd redis-2.4.11
#src/REDIS-CLI
#redis 127.0.0.1:6379> set foo bar
Ok
#redis 127.0.0.1:6379> get foo
"Bar"

2. Install Phpredis module

#wget Https://nodeload.github.com/owlient/phpredis/zipball/master
#unzip Owlient-phpredis-2.1.1-1-g90ecd17.zip
#cd/usr/src/owlient-phpredis-90ecd17/
#/usr/local/php-5.2.17/bin/phpize

#./configure–with-php-config=/usr/local/php-5.2.17/bin/php-config

#make
#make Install
To modify the php.ini file:

Add to

Extension_dir = "/usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613/"

Extension=redis.so
Restart the Web service (I'm using nginx here)

Write a simple PHP configuration view the test page info.php:

<?php

Phpinfo ();

?>

Enter in the browser: http://localhost/info.php to see if PHP supports Redis

Related Article

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.