1
|
sudo easy_install redis
|
1
2
3
|
1
|
easy_install hiredis
|
1
2
3
4
5
6
7
|
import
redis
r
=
redis.StrictRedis(host
=
'127.0.0.1'
, port
=
9212
)
r.
set
(
'foo'
,
'hello'
)
r.rpush(
'mylist'
,
'one'
)
print
r.get(
'foo'
)
print
r.rpop(
'mylist'
)
|
1
2
3
4
5
6
7
8
|
import
redis
pool
=
redis.ConnectionPool(host
=
'127.0.0.1'
, port
=
9212
)
r
=
redis.Redis(connection_pool
=
pool)
r.
set
(
'one'
,
'first'
)
r.
set
(
'two'
,
'second'
)
print
r.get(
'one'
)
print
r.get(
'two'
)
|
1
2
3
4
5
6
7
8
9
10
|
import
redis
pool
=
redis.ConnectionPool(host
=
'127.0.0.1'
, port
=
9212
)
r
=
redis.Redis(connection_pool
=
pool)
pipe
=
r.pipeline()
pipe.
set
(
'one'
,
'first'
)
pipe.
set
(
'two'
,
'second'
)
pipe.execute()
pipe.
set
(
'one'
.
'first'
).rpush(
'list'
,
'hello'
).rpush(
'list'
,
'world'
).execute()
|
1
|
pipe
=
r.pipeline(transaction
=
False
)
|