redis list操作

redis 127.0.0.1:6379[1]> lpush program java

(integer) 1

redis 127.0.0.1:6379[1]> lpush program javascript

(integer) 2

redis 127.0.0.1:6379[1]> lpush program javascript ruby

(integer) 4

redis 127.0.0.1:6379[1]> llen program

(integer) 4

redis 127.0.0.1:6379[1]> ltrim program 0 -1

OK

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "ruby"

2) "javascript"

3) "javascript"

4) "java"

redis 127.0.0.1:6379[1]> lpush program html

(integer) 5

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "html"

2) "ruby"

3) "javascript"

4) "javascript"

5) "java"

redis 127.0.0.1:6379[1]> rpush program redis

(integer) 6

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "html"

2) "ruby"

3) "javascript"

4) "javascript"

5) "java"

6) "redis"

redis 127.0.0.1:6379[1]> ltrim program 0 4

OK

redis 127.0.0.1:6379[1]> llen program

(integer) 5

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "html"

2) "ruby"

3) "javascript"

4) "javascript"

5) "java"

redis 127.0.0.1:6379[1]> lrem program 1 javascript

(integer) 1

redis 127.0.0.1:6379[1]> lrange 0 -1

(error) ERR wrong number of arguments for 'lrange' command

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "html"

2) "ruby"

3) "javascript"

4) "java"

redis 127.0.0.1:6379[1]> rpush program java

(integer) 5

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "html"

2) "ruby"

3) "javascript"

4) "java"

5) "java"

redis 127.0.0.1:6379[1]> lrem program 0 java

(integer) 2

redis 127.0.0.1:6379[1]> llen program

(integer) 3

redis 127.0.0.1:6379[1]> lpush program ruby

(integer) 4

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "ruby"

2) "html"

3) "ruby"

4) "javascript"

redis 127.0.0.1:6379[1]> lrem program -1 ruby 

(integer) 1

redis 127.0.0.1:6379[1]> lrange program 0 -1

1) "ruby"

2) "html"

3) "javascript"

你可能感兴趣的:(redis,redis-cli,lpush,rpop,lrange)