|
redis 127.0.0.1:6379> incr book_id # with book_id this Key Save Book of the table ID, every time you want to get a new
#book_id self-increment with incr command
(integer) 1
#incr command to return 1, then use Key to be book:1 of the Hash to save a Book Object , Object properties are Hash of the Field
Redis 127.0.0.1:6379> hset book:1 name "The Ruby programming Language"
(integer) 1
Redis 127.0.0.1:6379> hset book:1 Author "Mark Pilgrim"
(integer) 1
redis 127.0.0.1:6379> hgetall book:1 # with Hgetall command to test a , return Hash all the properties and values
1) "Name"
2) "The Ruby programming Language"
3) "Author"
4) "Mark Pilgrim"
redis 127.0.0.1:6379> incr book_id # Create the Section 2 a Book Object , First incr a book_id Get new Book of the ID
(integer) 2
Redis 127.0.0.1:6379> hset book:2 name "Ruby on rail"
(integer) 1
Redis 127.0.0.1:6379> hset book:2 Author "David Flanagan"
(integer) 1
Redis 127.0.0.1:6379> Hgetall Book:2
1) "Name"
2) "Ruby on Rail"
3) "Author"
4) "David Flanagan"
Redis 127.0.0.1:6379> incr book_id
(integer) 3
Redis 127.0.0.1:6379> hset book:3 name "Programming Erlang"
(integer) 1
Redis 127.0.0.1:6379> hset book:3 Author "Joe Armstrong"
(integer) 1
Redis 127.0.0.1:6379> Hgetall Book:3
1) "Name"
2) "Programming Erlang"
3) "Author"
4) "Joe Armstrong"
|