Redis 入门系列-redis-redis脚本,连接,服务

目录

Redis 脚本

Redis 脚本使用 Lua 解释器来执行脚本。 Reids 2.6 版本通过内嵌支持 Lua 环境。执行脚本的常用命令为 EVAL。

语法

Eval 命令的基本语法如下:

6379> EVAL script numkeys key [key ...] arg [arg ...]

实例

redis:6379> EVAL "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second
1) "key1"
2) "key2"
3) "first"
4) "second"

Redis 脚本命令

序号 命令 说明
1 EVAL script numkeys key [key ...] arg [arg ...] 执行 Lua 脚本
2 EVALSHA sha1 numkeys key [key ...] arg [arg ...] 执行 Lua 脚本
3 SCRIPT EXISTS script [script ...] 查看指定的脚本是否已经被保存在缓存当中
4 SCRIPT FLUSH 从脚本缓存中移除所有脚本
5 SCRIPT KILL 杀死当前正在运行的 Lua 脚本
6 SCRIPT LOAD script 将脚本 script 添加到脚本缓存中,但并不立即执行这个脚本

Redis 连接

Redis 连接命令主要是用于连接 redis 服务

实例

redis:6379> auth 
(error) ERR wrong number of arguments for 'auth' command
redis:6379> auth 123456
(error) ERR Client sent AUTH, but no password is set
redis:6379> ping
PONG

Redis 连接命令

序号 命令 说明
1 AUTH password 验证密码是否正确
2 ECHO message 打印字符串
3 QUIT 关闭当前连接
4 SELECT index 切换到指定的数据库

Server

服务命令

实例

info 命令如下

redis:6379> info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:22c6ee099916a58b
redis_mode:standalone
os:Linux 4.9.87-linuxkit-aufs x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.9.2
process_id:1
run_id:79a4c0448e46c758cdf9c3d93cbc559b42f67a59
tcp_port:6379
uptime_in_seconds:514213
uptime_in_days:5
hz:10
lru_clock:16520790
executable:/data/redis-server
config_file:

# Clients
connected_clients:2
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:870576
used_memory_human:850.17K
used_memory_rss:3502080
used_memory_rss_human:3.34M
used_memory_peak:870576
used_memory_peak_human:850.17K
used_memory_peak_perc:100.00%
used_memory_overhead:853544
used_memory_startup:786448
used_memory_dataset:17032
used_memory_dataset_perc:20.25%
total_system_memory:2095771648
total_system_memory_human:1.95G
used_memory_lua:40960
used_memory_lua_human:40.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:4.02
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1526469077
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:303104
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

# Stats
total_connections_received:5
total_commands_processed:71
instantaneous_ops_per_sec:0
total_net_input_bytes:2797
total_net_output_bytes:55140
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:13
keyspace_misses:2
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:5985
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

# Replication
role:master
connected_slaves:0
master_replid:eefbcbf7c8d56362978e2f175e7a7244dbd0a02d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:456.40
used_cpu_user:77.01
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=12,expires=0,avg_ttl=0

目录索引

目录索引

猜你喜欢

转载自blog.csdn.net/ryo1060732496/article/details/80341800