python下redis的基本操作:

1. 基本操作:

>>> import redis
>>> print redis.__file__
/usr/local/lib/python2.7/dist-packages/redis/__init__.pyc
>>> redisClient = redis.Redis(host='127.0.0.1', port=6379, db=0)
>>> info = redisClient.info()
>>> for key in info:
... print "%s:%s" %(key, info[key])
...
aof_rewrite_in_progress:0
total_connections_received:8
run_id:0a62a8d1e52971400a930715b8f621e05a26ba8b
rejected_connections:0
redis_build_id:cee0f9a49c3c27aa
used_memory_peak_human:578.38K
pubsub_patterns:0
redis_mode:standalone
connected_slaves:0
db2:{'keys': 179, 'expires': 0, 'avg_ttl': 0}
uptime_in_days:0
multiplexing_api:epoll
lru_clock:9571444
redis_version:2.8.13
redis_git_sha1:0
sync_partial_ok:0
gcc_version:4.9.1
connected_clients:2
keyspace_misses:4
used_memory:590392
tcp_port:6379
master_repl_offset:0
used_cpu_user_children:0.0
repl_backlog_first_byte_offset:0
rdb_current_bgsave_time_sec:-1
pubsub_channels:0
used_cpu_user:1.96
used_memory_lua:33792
instantaneous_ops_per_sec:0
rdb_last_save_time:1435633828
total_commands_processed:141
aof_last_write_status:ok
role:master
aof_rewrite_scheduled:0
sync_partial_err:0
used_memory_rss:7311360
hz:10
sync_full:0
aof_enabled:0
config_file:/etc/redis/redis.conf
used_cpu_sys:3.1
rdb_last_bgsave_status:ok
latest_fork_usec:135
aof_last_bgrewrite_status:ok
db4:{'keys': 7, 'expires': 6, 'avg_ttl': 721067416}
aof_last_rewrite_time_sec:-1
used_memory_human:576.55K
loading:0
blocked_clients:0
process_id:2006
db0:{'keys': 3, 'expires': 0, 'avg_ttl': 0}
repl_backlog_histlen:0
client_biggest_input_buf:0
aof_current_rewrite_time_sec:-1
arch_bits:64
repl_backlog_active:0
mem_fragmentation_ratio:12.38
rdb_last_bgsave_time_sec:0
expired_keys:0
used_cpu_sys_children:0.01
evicted_keys:0
rdb_bgsave_in_progress:0
repl_backlog_size:1048576
client_longest_output_list:0
mem_allocator:jemalloc-3.6.0
used_memory_peak:592256
db3:{'keys': 1, 'expires': 1, 'avg_ttl': 686672452}
uptime_in_seconds:9532
rdb_changes_since_last_save:0
redis_git_dirty:0
os:Linux 3.16.0-37-generic x86_64
keyspace_hits:43
>>>
上一篇:Redis 的基本操作、Key的操作及命名规范


下一篇:java对redis的基本操作