redis中文API

來源:互聯網
上載者:User
  redis中文API 分類: 資料庫 2012-06-12 17:38  1412人閱讀  評論(1)  收藏  舉報 redis api list dataset 伺服器 database

REDIS所有的命令

<<ABOUT LIST>>

lpop key :                    刪除並取得list頭部一個元素
rpop key :                    刪除並取得list尾部一個元素
blpop key [key ...] timeout : 刪除並取得list頭部一個元素,如果沒有就block
brpop key [key ...] timeout : 刪除並取得list尾部一個元素,如果沒有就block
lpush key value :             在list頭部擴充一個元素
rpush key value :             在list尾部擴充一個元素
lpushx key value :            如果list存在,在list頭部擴充一個元素
rpushx key value :            如果list存在,在list尾部擴充一個元素
lindex key index :            通過index取得list的一個元素
llen key :                    取得list的長度
lrange key start stop :       取得list在指定範圍內的元素
lrem key count value :        刪除list的元素們
lset key index value :        設定list索引為index的元素的值
ltrim key start stop :        裁剪list,保留一定範圍的元素
rpoplpush source destination :刪除當前list的尾部一個元素,並將其擴充到另一個list的尾部
brpoplpush source destination timeout :
                             彈出list一個元素,並將其插入到另一個list裡,然後返回,如果前個list空就block
sort key [by pattern] [limit offset count] [get pattern [get pattern ...]] [asc|desc] [alpha] [store destination] :
                             排序list,set, sorted set
<<about set>>
sadd key member :                       向set中添加一個成員
srem key member :                       從set中刪除一個成員
sdiff key [key ...] :                   集合求差集
sinter key [key ...] :                  集合求交集
sunion key [key ...] :                  集合求並集
sdiffstore destination key [key ...] :  集合求差集,並儲存結果集到另一集合
sinterstore destination key [key ...] : 集合求交集,並儲存結果集到另一集合
sunionstore destination key [key ...] : 集合求並集,並儲存結果集到另一集合
scard key :                             取得set成員總數
sismember key member :                  判斷給定值是否為set成員
spop key :                              刪除並返回set任一成員
srandmember key :                       返回set任一成員
smembers key :                          取得set所有成員
smove source destination member :       將一個set中一個成員移動到另一個set中
<<about sorted set>>
zadd key score member :                 在sset中添加一個成員,或者說更新已有成員的score
zcard key :                             取得sset的成員總數
zcount key min max :                    計算sset中score在一個給定範圍內的成員總數
zincrby key :                           為sset中的成員自增score
zinterstore destination numkeys key [key ...] [weights weight [weight ...]] [aggregate sum|min|max] :
                                       求sset交集,並將結果集儲存到一個新key
zrange key start stop [withscores] :    返回sset中一定index範圍內的成員
zrangebyscore key min max [withscores] [limit offset count] : 返回sset中一定score範圍內的成員
zrem key member :                       刪除sset中一個成員
zremrangebyrank key start stop :        刪除sset一定index範圍內的成員
zremrangebyscore key min max :          刪除sset一定score範圍內的成員
zrevrange key start stop [withscores] : 返回sset中一定index範圍內的成員,其順序是score從高到低
zrevrangebyscore key max min [withscores] [limit offset count] : 返回sset中一定score範圍內的成員,其順序是score從高到低
zscore key member :                     獲得sset中與給定member關聯的score
zunionstore destination numkeys key [key ...] [weights weight [weight ...]] [aggregate sum|min|max] :
                                       sset求並集,並將結果集存到一個新的key中
<<about hash>>
hdel key field :                            刪除一個hashfield
hexists key field :                         判斷一個hashfield是否存在
hget key field :                            獲得一個hashfield的值
hgetall key :                               獲得一個hash所有的fields和values
hincrby key field increment :               對hashfield的整數值增加increment的整數值
hkeys key :                                 獲得hash所有的field
hlen key :                                  獲得hash內field總數
hmget key field [field ...] :               獲得hash指定field的所有值
hmset key field value [field value ...] :   設定hash的一些filed和value
hset key field value :                      設定hash的某field為某值
hsetnx key field value :                    當hash的某field不存在時候,設定其為某值
hvals key :                                 獲得hash的所有值
<<about key>>
del key [key ...] :         刪除一個key
get key :                   獲得一個key的值
setex key seconds value :   設定key的value和exp時間
setnx key value :           設定key的value,前提是key之前不存在
set key value :             設定key,value
append key value :          向一個key擴充一個值
debug object key :          獲得一個key的debug資訊
decr key :                  給一個key-1
decrby key integer :        給一個key-integer
exists key :                判斷一個key是否存在
expire key seconds :        設定一個key的ttl(second)
expireat key timestamp :    設定一個key的ttl(unix timestamp)
ttl key :                   獲得key的ttl
persist key :               刪除一個key的到期標誌
keys pattern :              尋找所有符合pattern的key
move key db :               將一個key移動到另一個database中
rename key newkey :         重新命名一個key
renamenx key newkey :       給一個key重新命名,前提是新keyname不存在
randomkey :                 從keyspace返回一個任一的key
<<about value>>
getrange key start end :            獲得key對應的字串裡指定範圍的子串
getset key value :                  設定key對應的value,並返回老的value
incr key :                          為key對應的整數值自增1
incrby key increment :              為key對應的整數值自增increment
mget key [key ...] :                獲得所有指定key的值
mset key value [key value ...] :    為指定的keys設定指定的values
msetnx key value [key value ...] :  當指定的key存在時候,為指定的keys設定指定的values
strlen key :                        獲得key的value長度
<<about server>>
info :                                          獲得伺服器的狀態資訊和統計資訊
monitor :                                       即時監聽server獲得的所有請求
ping :                                          ping伺服器
quit :                                          關閉連結
publish channel message :                       發布一個訊息到一個channel
auth password :                                 證明伺服器
lastsave :                                      獲得最後一次成功savetodisk的時間戳記
object subcommand [arguments [arguments ...]] : 偵測redis對象的內部
psubscribe pattern [pattern ...] :              監聽發布到channel的所有符合pattern的訊息
punsubscribe [pattern [pattern ...]] :          停止監聽發布到channel的所有符合pattern的訊息
config resetstat :                              重設info命令返回的狀態資訊
subscribe channel [channel ...] :               監聽指定channel的訊息
unsubscribe [channel [channel ...]] :           停止監聽指定channel的訊息
unwatch : forget about all watched keys         停止監視所有被監視的key
watch key [key ...] :                           監視所有給定的key,來判斷multi和exec塊的執行
<<about database>>
save synchronously :    儲存dataset到硬碟
select index :          切換當前資料庫
bgsave :                非同步儲存dataset到硬碟
dbsize :                    返回一個database的key總數
flushall :                  刪除所有database上所有的key
flushdb :                   刪除當前database上所有的key
shutdown synchronously :                        儲存dataset到硬碟後,關閉伺服器
<<configure>>
config get parameter :          獲得一個配置參數值
config set parameter value :    設定一個配置參數為給定值
<<other>>
getbit key offset :             返回key對應的value在offset的位元值
multi :                         標識一個業務塊的開始
setrange key offset value :     從指定的offset開始覆蓋寫key對應的value串
bgrewriteaof :                  非同步重寫append-only file
debug segfault :                使伺服器crash
discard :                       忽略所有的以multi開頭的命令
echo message :                  echo message
exec :                          執行所有以multi開頭的命令
slaveof host port :             使本伺服器成為另一redis host的slave,或者使本伺服器成為主伺服器
sync :                          內部備份命令
linsert key before|after refvalue value : 向列表key的refvalue之前或者之後插入value
zrank key member : determine the index of a member in a sorted set
zrevrank key member : determine the index of a member in a sorted set, with scores ordered from high to low
setbit key offset value : sets or clears the bit at offset in the string value stored at key
type key : determine the type stored at key

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.