Home  >  Article  >  Backend Development  >  php-redis Chinese Document No. 4

php-redis Chinese Document No. 4

WBOY
WBOYOriginal
2016-07-25 09:05:45841browse
This article is the fourth part of the php-redis Chinese documentation. Friends in need can refer to it.

This article is the fourth part of the php-redis Chinese documentation. Friends in need can refer to it.

getRange (method does not exist) Returns the characters between start and end in the string named key $redis->set('key', 'string value'); $redis->getRange('key', 0, 5); $redis->getRange('key', -5, -1); setRange (method does not exist) Change the characters between start and end in the key string to value $redis->set('key', 'Hello world'); $redis->setRange('key', 6, "redis"); $redis->get('key'); strlen Get the length of the key string $redis->strlen('key'); getBit/setBit Return binary information zset (sorted set) operation related zAdd(key, score, member): Add element member to the zset named key, score is used for sorting. If the element already exists, the order of the elements is updated based on the score. $redis->zAdd('key', 1, 'val1'); $redis->zAdd('key', 0, 'val0'); $redis->zAdd('key', 5, 'val5'); $redis->zRange('key', 0, -1); // array(val0, val1, val5) zRange(key, start, end,withscores): Returns all elements with index from start to end in the zset named key (the elements have been sorted from small to large by score) $redis->zAdd('key1', 0, 'val0'); $redis->zAdd('key1', 2, 'val2'); $redis->zAdd('key1', 10, 'val10'); $redis->zRange('key1', 0, -1); // with scores $redis->zRange('key1', 0, -1, true); zDelete, zRem zRem(key, member): Delete the element member in the zset named key $redis->zAdd('key', 0, 'val0'); $redis->zAdd('key', 2, 'val2'); $redis->zAdd('key', 10, 'val10'); $redis->zDelete('key', 'val2'); $redis->zRange('key', 0, -1); zRevRange(key, start, end,withscores): Returns all elements with index from start to end in the zset named key (the elements have been sorted from large to small by score).withscores: Whether to output the value of socre, default false, No output $redis->zAdd('key', 0, 'val0'); $redis->zAdd('key', 2, 'val2'); $redis->zAdd('key', 10, 'val10'); $redis->zRevRange('key', 0, -1); // with scores $redis->zRevRange('key', 0, -1, true); zRangeByScore, zRevRangeByScore $redis->zRangeByScore(key, star, end, array(withscores, limit )); Returns score >= star in the zset named key and score zCount(key, star, end); Returns the score in the zset named key >= star and score zRemRangeByScore('key', star, end); Delete the score >= star in the zset named key and score zScore(key, val2); Returns the score of element val2 in the zset named key zRank, zRevRank $redis->zRevRank(key, val); Returns the rank (i.e. index, starting from 0) of the val element in the zset named key (the elements have been sorted from small to large by score). If there is no val element, return "null". zRevRank is sorted from large to small zIncrBy $redis->zIncrBy('key', increment, 'member'); If the element member already exists in the zset named key, the score of the element is increased by increment; otherwise, the element is added to the set, and the value of its score is increment. zUnion/zInter parameter keyOutput arrayZSetKeys arrayWeights aggregateFunction Either "SUM", "MIN", or "MAX": defines the behavior to use on duplicate entries during the zUnion. Find the union and intersection of N zsets, and save the final set in dstkeyN. The score of each element in the collection must be multiplied by the WEIGHT parameter before performing the AGGREGATE operation. If WEIGHT is not provided, it defaults to 1. The default AGGREGATE is SUM, that is, the score of the element in the result set is the value of the SUM operation of the corresponding elements of all sets, and MIN and MAX mean that the score of the element in the result set is the minimum and maximum values ​​of the corresponding elements of all sets.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn