タイプ一般的に使用されるメソッドリストのRedisの
フォーマット:
存--- LPUSHキー値[値...]
取--LRANGEキー、スタートストップ
lpushキー値[値...] 1つ以上の値がリストの先頭に挿入されます
127.0.0.1:6379> lpush plf panlifu (integer) 1 127.0.0.1:6379> lpush plf lt (integer) 2 127.0.0.1:6379> lpush plf xs (integer) 3 127.0.0.1:6379> lpush plf cd (integer) 4 127.0.0.1:6379> lrange plf 0 1 1) "cd" 2) "xs" 127.0.0.1:6379> lrange plf 0 3 1) "cd" 2) "xs" 3) "lt" 4) "panlifu"
スタートキーLRANGE指定された範囲内の要素のリストを取得停止
127.0.0.1:6379> lpush plf panlifu (integer) 1 127.0.0.1:6379> lpush plf lt (integer) 2 127.0.0.1:6379> lpush plf xs (integer) 3 127.0.0.1:6379> lpush plf cd (integer) 4 127.0.0.1:6379> lrange plf 0 1 1) "cd" 2) "xs" 127.0.0.1:6379> lrange plf 0 3 1) "cd" 2) "xs" 3) "lt" 4) "panlifu"
キー[キー...]タイムアウトblpop最初の要素とリストは要素のリストでない場合は、リストから抜け出すタイムアウトするまでブロックするか、ポップアップ要素を見つけることができるようになるまで待ちます
127.0.0.1:6379> blpop plf timeout 1 1) "plf" 2) "cd" 127.0.0.1:6379> lrange plf 0 4 1) "xs" 2) "lt" 3) "panlifu"
キー[キー...]タイムアウトをbrpopとリストがタイムアウトするまでブロックしたり、発見が要素をポップするまで待つことになる要素のリストがない場合は、リストの最後の要素から抜け出します。
127.0.0.1:6379> lrange plf 0 4 1) "xs" 2) "lt" 3) "panlifu" 127.0.0.1:6379> brpop plf timeout 1 1) "plf" 2) "panlifu" 127.0.0.1:6379> lrange plf 0 4 1) "xs" 2) "lt"
brpoplpushソース先のタイムアウトは、別のリストには、リストからポップアップ要素を値をポップし、それを返し、リストは待機タイムアウトするまでブロック、またはポップアップ要素をこれまでに見つけることができるでしょう要素が表示されない場合。?
127.0.0.1:6379> brpoplpush plf lt timeout 10 (error) ERR wrong number of arguments for 'brpoplpush' command 127.0.0.1:6379>
インデックスで要素のリストを取得するLINDEXキーインデックス
127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "lt" 127.0.0.1:6379> lindex plf 1 "lt" 127.0.0.1:6379> lindex plf 0 "xs" 127.0.0.1:6379>
linsertのキーの前に|前または後の要素のリストでピボット値の挿入要素AFTER
127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "lt" 127.0.0.1:6379> linsert plf after lt hehe (integer) 3 127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "lt" 3) "hehe" 127.0.0.1:6379> linsert plf before lt hehe (integer) 4 127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "hehe" 3) "lt" 4) "hehe"
リストの長さを取得するllenキー
127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "hehe" 3) "lt" 4) "hehe" 127.0.0.1:6379> llen plf (integer) 4
キーLPOP最初の要素を除去し、のリストを取得します
127.0.0.1:6379> lrange plf 0 3 1) "xs" 2) "hehe" 3) "lt" 4) "hehe" 127.0.0.1:6379> llen plf (integer) 4 127.0.0.1:6379> lpop plf "xs" 127.0.0.1:6379> lrange plf 0 3 1) "hehe" 2) "lt" 3) "hehe"
lpushxキー値ヘッダが既に存在している値のリストに挿入されます
```shell
127.0.0.1:6379> lpushx hehe hello
(error) WRONGTYPE Operation against a key holding the wrong kind of value
127.0.0.1:6379> lpushx plf hello
(integer) 4
127.0.0.1:6379> lrange plf 0 5
1) "hello"
2) "hehe"
3) "lt"
4) "hehe"
```
lremキーカウント値は、リストの要素を削除し、回数をカウント
127.0.0.1:6379> lrange plf 0 5 1) "hello" 2) "hehe" 3) "lt" 4) "hehe" 127.0.0.1:6379> lrem plf 2 hehe (integer) 2 127.0.0.1:6379> lrange plf 0 5 1) "hello" 2) "lt"
リスト要素のインデックス値を設定することで、キーインデックス値をLSET
127.0.0.1:6379> lrange plf 0 5 1) "hello" 2) "lt" 127.0.0.1:6379> lset plf 0 gunkai OK 127.0.0.1:6379> lrange plf 0 5 1) "gunkai" 2) "lt"
LTRIMトリム(トリム)のリストについては、スタートキーストップは、それは、削除されます指定されていないの範囲内の要素の範囲内でのみ指定された保持要素のリストを作成しています。
127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1" 4) "2" 5) "3" 6) "4" 7) "5" 8) "6" 9) "7" 10) "8" 127.0.0.1:6379> ltrim plf 0 3 OK 127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1" 4) "2"
RPOPキーは、リストの最後の要素、削除要素の戻り値を削除します。
127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1" 4) "2" 127.0.0.1:6379> rpop plf "2" 127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1"
rpoplpushソース先は、リストの最後の要素を削除し、別のリストを返すに要素を追加します
127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1" 127.0.0.1:6379> rpoplpush plf lt "1" 127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 127.0.0.1:6379> lrange lt 0 10 1) "1"
リスト内の1つ以上の値を追加するために[...値]キー値をrpush
127.0.0.1:6379> lrange plf 0 5 1) "gunkai" 2) "lt" 127.0.0.1:6379> rpush plf 1 2 3 4 5 6 7 8 (integer) 10 127.0.0.1:6379> lrange plf 0 10 1) "gunkai" 2) "lt" 3) "1" 4) "2" 5) "3" 6) "4" 7) "5" 8) "6" 9) "7" 10) "8"
rpushxキー値既存のリストに値を追加します
127.0.0.1:6379> rpushx test_key 1 (integer) 0 127.0.0.1:6379> lrange test_key 0 1 (empty list or set)
要約:終了Xキーが存在するかどうかを決定することである、不在は、プレゼンスを設定するために、設定することができません。Rは、同時に添加することができる複数の値を持つ開始を表します