One. String (String)
1.set: Set key$reids->set (' MyKey ', 111); 2.get: Gets the key $redis->get (' MyKey ');3.del: Delete key$redis->del (' MyKey ');4.append: Append$redis->append (' MyKey ', ' 222 ');5.exists: Check if key exists$reids->exists (' MyKey ');6.incr/incrby,decr/decrby: Add and Subtract keys (key does not exist default is 0)A. Integer type, this operation is supported in 64-bit signed integer number $redis->incr (' MyKey '),//plus 1 $redis->incrby (' MyKey ', 5);//plus 5 $redis->decr (' MyKey ' );//minus 1 $redis->decrby (' MyKey ', 5);//minus 5 B. Floating-point $redis->set (' MyKey ', 1.2); $redis->incrbyfloat (' MyKey ', 0.1);7.getrange: Gets a substring of the value stored on the key$redis->set (' MyKey ', ' This is a string '); echo $redis->getrange (' MyKey ', 0,2); Output ' Thi '8.getset: Sets the value of a key and gets the values before the set (returns the previous old value if the previous key does not exist will return nil. )$redis->incrby (' MyKey ', 5); $redis->getset (' MyKey ', 0);//Output 5 $redis->get (' MyKey ');//Output 09.setnx: Sets the key to value, and if key does not exist, this is equivalent to the SET command. When key is present, nothing is done. Setnx is a shorthand for "SET if not eXists". $redis->setnx (' MyKey ', ' Hello ');//Output 1 $redis->setnx (' MyKey ', ' World ')://Output 0 $redis->get (' MyKey ');//Output Hello10.mset: Set multiple key value$redis->mset ([' Key1 ' =>1, ' Key2 ' =>2]); echo $redis->get (' Key1 ');11.mget: Get the value of all keys$redis->set (' Key1 ', ' Hello '); $redis->set (' Key2 ', ' Word '); $array = $redis->mget ([' Key1 ', ' key2 ', ' Key3 ']);12.MSETNX: Set multiple key value, only if key exists$redis->msetnx ([' Key1 ' =>1, ' Key2 ' =>2]);//Output 1 $redis->msetnx ([' Key2 ' =>2, ' Key3 ' =>3]);//Output 0 $ Redis->mget ([' Key1 ', ' Key2 ']);//Output key1=>1,key2=>213.strlen:key the length of the corresponding string value, or 0 (key does not exist)$redis->strlen (' MyKey ');14.setex: Set the key expiration time in seconds$redis->setex (' MyKey ', ten, ' value ') is equivalent to executing $redie->set (' MyKey ', ' value '); $redis->expire (' MyKey ', 10);
Php-redis command Strings (String)