One of the php-redis Chinese documents

Source: Internet
Author: User
One of the php-redis Chinese documents
This article is the first part of the php-redis Chinese document. it mainly introduces some of the commands officially provided by redis. if you need it, refer to it.

This article is the first part of the php-redis Chinese document. it mainly introduces some of the commands officially provided by redis. if you need it, refer to it.

As an extension of php, phpredis is highly efficient and has the linked list sorting function, which is useful for creating memory-level module business relationships;

: Https://github.com/owlient/phpredis (support for redis 2.0.4)

Redis :__ construct $ Redis = new redis (); connect, open link Redis service parameter host: string, service address port: int, port number timeout: float, link duration (optional, default value: 0, unlimited link time) Note: in redis. the conf file also has time. the default value is 300 pconnect, for links that popen does not close, refer to the above setOption settings redis mode getOption view redis mode ping view connection status get a key value (string value) if the key does not exist, return false set write key and value (string value) if the write is successful, return ture setex write value with survival time $ redis-> setex ('key', 3600, 'value'); // sets key → value, with 1 h TTL. setnx indicates whether the request is repeated. the written value $ redis-> setnx ('key', 'value'); $ redis-> setnx ('key', 'value '); delete: returns the number of deleted keys (long integer) $ redis-> delete ('key1', 'key2 '); $ redis-> delete (array ('key3', 'key4', 'key5 ')); ttl: Get the ttl of a key. persist: remove the expired key. if the key expires, true is returned. if the key does not expire, false is returned.

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.