-
一、分布式锁是什么
分布式锁是 满足分布式系统或集群模式下多进程可见并且互斥的锁。
基于Redis实现分布式锁:
1、获取锁
互斥:确保只能有一个线程获取锁;非阻塞:尝试获取锁,成功返回
-
一。Redis实现分布式锁原理
为什么需要分布式锁
在聊分布式锁之前,有必要先解释一下,为什么需要分布式锁。
与分布式锁相对就的是单机锁,我们在写多线程程序时,避免同时操作一个共享
-
常用的分布式ID解决方案
在分布式系统中,生成全局唯一ID是非常重要的,因为在分布式系统中,多个节点同时生成ID可能会导致ID冲突。
下面介绍几种常用的分布式ID解决方案。
UUID
UUID(通用
-
1.redis 用zset做消息队列如何处理消息积压
改变消费者的消费能力:
可以增加消费者的数量,或者优化消费者的消费能力,使其能够更快地处理消息。同时,可以根据消息队列中消息的
-
这次的前后端分离这个问题就出现了,下面就来解决这个问题。
一、遇到的情况
在登录controller中的login方法里,登录成功后将值存到session中
request.getSession().setAttribute("administrator",admin.getId());
-
一.多线程下引起的超卖问题呈现
1.1.我先初始化库存数量为1、订单数量为0
1.2.开启3个线程去执行业务
业务为:判断如果说库存数量大于0,则库存减1,订单数量加1
结果为:库存为-2,订单数
-
为什么redis要设置密码?
内网环境可以不设置密码,但是个人服务器,以及线上公网服务器就有必要设置密码了。
昨天我查看了一下minio的redis事件通知,查看redis的key时发现多了几个奇怪的key
-
最近遇到一个比较紧急的任务,要求统计在线用户,目的是配合性能测评,要求证明自己系统的在线用户能够达标,不过系统因为历史原因,并没有这个功能,所以只能去springSession官网和网上
-
摘要
Redis是一款性能强劲的内存数据库,但是在使用过程中,我们可能会遇到Big Key问题,这个问题就是Redis中某个key的value过大,所以Big Key问题本质是Big Value问题,导致Redis的性能下降或者崩溃
-
1. HyperLogLog 的原理
Redis HyperLogLog基于一种称为HyperLogLog算法的概率性算法来估计基数。 HyperLogLog使用一个长度为m的位数组和一些hash函数来估计集合中的唯一元素数。
在 HyperLogLog 算法中,对
-
摘要
Redis是一款开源的高性能key-value数据库,广泛应用于各种场景。在Redis中,数据类型(type)和编码(encoding) 是非常重要的概念。本篇博客将详细介绍Redis支持的数据类型以及相应的编码方
-
内存碎片
内存碎片如何产生的?
Redis内部有自己的内存分配器,默认是jemalloc,为了提高内存使用的效率,来对内存的申请和释放进行管理。 而内存分配器按照固定大小分配内存,并不是完全
-
1 第一个坑:错误释放锁时机
1.1. 发现问题
分析以下代码存在什么问题:
// 分布式锁服务
public interface RedisLockService {
// 获取锁
public boolean getLock(String key);
// 释放锁
public boolean release
-
引言
大厂很多项目都是部署到多台服务器上,这些服务器在各个地区都存在,当我们访问服务时虽然执行的是同一个服务,但是可能是不同服务器运行的;
在我学习项目时遇到这样一个登录情
-
今天搞一下经典面试题Redis为什么选择单线程?Redis为什么这么快?,实现快速入门,丰富个人简历,提高面试level,给自己增加一点谈资,秒变面试小达人,BAT不是梦。
一、Redis版本迭代
Redis2.