redis
一颗小松丸
平均写代码速度:20根头发/分钟
展开
-
RedisUtil工具类
RedisTemplate import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.Col原创 2021-08-30 13:30:05 · 103 阅读 · 0 评论 -
Redis Template固定模板
@Configuration public class RedisConfig { //RedisTemplate固定模板 @Bean public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { RedisTemplate<String, Object> template = new RedisTemplate<>().原创 2021-08-30 13:01:56 · 257 阅读 · 0 评论 -
Docker安装Redis
# Redis configuration file example. # # Note that in order to read the configuration file, Redis must be # started with the file path as first argument: # # ./redis-server /path/to/redis.conf # Note on units: when memory size is needed, it is possible to原创 2021-08-28 20:58:53 · 68 阅读 · 0 评论 -
Docker安装Redis,Redis.conf配置
# Redis configuration file example. # # Note that in order to read the configuration file, Redis must be # started with the file path as first argument: # # ./redis-server /path/to/redis.conf # Note on units: when memory size is needed, it is possible t.原创 2021-08-28 20:57:49 · 697 阅读 · 0 评论 -
Redis缓存穿透、击穿、雪崩,分布式锁概述
1、缓存穿透 问题描述: 解决方案: 2、缓存击穿 问题描述: 解决方案: 3、缓存雪崩 问题描述: 解决方案: 4、分布式锁 ...原创 2021-08-28 10:18:15 · 99 阅读 · 0 评论 -
Redis主从复制设置
1.配置一主多从 首先创建一个目录,目录名就叫Redis 将redis的配置文件redis.conf复制到此目录下 同一个目录Redis下创建redis1.conf,redis2.conf 在Redis/redis.conf 文件中将AOF关闭 appendonly no 在redis1.conf中编辑下列内容 include /Redis/redis.conf pidfile /var/run/redis_6379.pid port 6379 dbfilename dump6379原创 2021-08-17 09:33:09 · 93 阅读 · 0 评论 -
Redis的RDB和AOF
1.RDB 在指定的时间间隔内将内存中的数据集快照写入磁盘,恢复时将快照文件直接读到内存。 备份:Redis单独创建(Frok)一个子进程进行持久化,会先将数据写入一个临时文件中,待持久化过程结束了再用临时文件替换上次持久化好的文件。 恢复:根据持久化后生成的文件恢复数据 相关配置: (1)save <时间> <数量>:如设置save 30 10,表示30秒内10个key改变则进行持久化操作, 将这10个ke...原创 2021-08-16 21:10:43 · 73 阅读 · 0 评论 -
使用jedis访问linux下的redis
1.首先在linux中安装好redis 2.更改redis中配置 (1)将此行代码注释了。 (2)关闭 redis 的保护模式,将 默认 yes 改为 no。 记得保存退出 esc :wq (3)为linux中的防火墙开放redis的端口 firewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload 3.创建 j...原创 2021-08-15 16:55:35 · 162 阅读 · 0 评论 -
Redis的基本数据类型的数据结构
1.String字符串 String的数据结构为简单动态字符串,类似于ArrayList。 当字符串长度小于1M时,扩容是加倍现有空间,超过1M,扩容时一次多扩容1M空间。字符串的最大长度为512M。 2.List列表 单键多值,1个key对应若干value 元素较少时使用 ziplist(连续内存存储),数据量较多则使用 quicklist (quicklist是通过双向链表将ziplist组合起来的) ...原创 2021-08-15 12:16:23 · 98 阅读 · 0 评论 -
Redis基本常用命令
1.Redis库 select * :切换数据库,redis有16个库(0-15),默认使用0号库 如:select 1:切换到1号库 dbsize :查看当前数据库的key的数量 flushdb :清空当前库(谨慎使用) flushall :清空全部库(谨慎使用) 2.键(key) keys * :查看当前库所有key exists key :判断某个key是否存...原创 2021-08-12 21:46:18 · 123 阅读 · 0 评论