First knowledge of PHP redis

Source: Internet
Author: User
Tags php redis

Official Website: http://redis.io/download

 

Windows

Reference to http://www.cnblogs.com/chenping-987123/archive/2012/01/29/2331079.html

I learned some basic operations

Redis-Server:

Redis-benchmark:

Redis-CLI:

 

Then PHP drops redis Extension

Version 5.2... It seems that it has not been updated:

Https://github.com/nicolasff/phpredis/downloads

Version 5.3 (php_redis-2.1.3-5.3-vc6-ts-4350b2a)

Http://ishare.iask.sina.com.cn/f/23044930.html? From = like

PHP drop-down document for decisive reference
Https://github.com/nicolasff/phpredis

To test with PHP

Reference

Http://hi.baidu.com/michael7768/blog/item/88a681a2835350b0cbefd0b2.html

?
1234567891011121314151617181920 <?php     $redis
= new
Redis();
    $redis->connect('127.0.0.1', 6379);
      $redis->set('key',
'value');       echo
$redis->get('key')."\n";
      $redis->setex('key', 3600,
'value'); // sets key → value, with 1h TTL.
      $redis->set('key1',
'val1');     $redis->set('key2',
'val2');     $redis->set('key3',
'val3');     $redis->set('key4',
'val4');       $redis->delete('key1',
'key2');     echo
$redis->get('key3')."\n"
;       $redis->delete(array('key3',
'key4')); ?>

 

Under Ubuntu

Download the tar.gz resource package and decompress make & make install to install it.

When starting redis-server, note that the redis. conf here is under/etc /.

/Usr/local/bin/redis-server/etc/redis. conf

Note the following when starting the drop: =. =

If the port is occupied, you can check who is occupied. If it is redis-server, force it off first...

Now let's test redis-CLI:

Oops! Redis is running ^-^

 

Now, you can compile PHP to expand redis. So.

CD to the source package directory (https://github.com/nicolasff/phpredis download)

'/Opt/lampp/bin/phpize'

./Configure-Prefix = '/opt/lampp/lib/PHP/extensions/no-debug-non-zts-20090626'-with-PHP-Config = '/opt/lampp/bin/PHP-config'

Make & make install

, You can pick up the goods at/home/Diandian/phpredis. Git/trunk/modules ^-^ (forgot whether to manually copy the CP or whether the file already exists in the extension region)

Then modify PHP. ini (Vim '/opt/lampp/etc/PHP. ini ')

Restart lampp.

Run the win example above.

Okay, run =. =

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.