redis
How To Install and Secure Redis on Ubuntu 22.04
登录 Redis 输入 keys '*sessions*' spring:session:sessions:db031986-8ecc-48d6-b471-b137a3ed6bc4 spring:session:expirations:1472976480000 Another Redis Desktop Manager 下载安装: https://github.com/qishibo/AnotherRedisDesktopManager/releases choco install another-redis-desktop-manager https://docs.spring.io/spring-session/reference/guides/boot-redis.html#boot-sample https://codeload.github.com/spring-projects/spring-session/zip/refs/tags/3.4.2
远程访问
#vim /etc/redis.conf #bind 127.0.0.1 :1:1 bind 0.0.0.0 daemonize no protected-mode no requirepass abc123password
#vim /etc/redis/redis.conf bind 127.0.0.1 ::1 requirepass abc123 redis-cli key '*' | xargs redis-cli del redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e redis-cli -h 127.0.0.1 -p 6379 > ping 测试连通 > auth password 密码连接 > select 1 选择其它数据库 > keys * 查看所有key > exists key 检查key是否存在 > expire key seconds 设置过期时间 > del key > flushdb 删除当前数据库所有key > flushall 删除所有数据库key ------------------------------------- > keys pattern 命令 patterns: h?llo matches hello, hallo and hxllo h*llo matches hllo and heeeello h[ae]llo matches hello and hallo, but not hillo h[^e]llo matches hallo, hbllo, ... but not hello h[a-b]llo matches hallo and hbllo keys *celery exists _kombu.binding.celery type _kombu.binding.celery get key set key value incr key +1 decr key -1 incrby key N decrby key N del key append key value 追加内容 getrange key start end 截取部分内容 dbsize 数据库总数,数据库id从0开始 select 1 选择数据库 move key 2 移动key到数据库2 ttl key 测试生命周期 ptll key 毫秒级, -1为永不过期 设置过期时间 expire key seconds pexpire key milisceond persist key 永不过期 更改键值名 rename key newkey 存放键值 set key value [EX seconds] [PX milliseconds] [NX|XX] nx:如果key不存在则建立,xx:如果key存在则修改其值,也可以直接使用setnx/setex命令。
wget http://download.redis.io/releases/redis-5.0.5.tar.gz tar -zxvf redis.tar.gz cd REDIS make cd src make install 设置后台启动: vim redis.conf daemonize yes 指定conf启动: redis-server redis.conf 设置开机启动: mkdir /etc/redis cp redis.conf /etc/redis/6379.conf cp utils/redis_init_script /etc/init.d/redisd vim /etc/init.d/redisd 在第一行后加入如下注释: # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database 注释的意思是,redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。 chkconfig redisd on service redisd start serivce redisd stop