crossoverJie / Distributed Redis Tool
Licence: mit
🔒A simple distributed tools based on Redis.
Stars: ✭ 577
Programming Languages
java
68154 projects - #9 most used programming language
Labels
Projects that are alternatives of or similar to Distributed Redis Tool
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (-8.32%)
Mutual labels: redis
Bloom
🌸 HTTP REST API caching middleware, to be used between load balancers and REST API workers.
Stars: ✭ 553 (-4.16%)
Mutual labels: redis
Javafamily
【Java面试+Java学习指南】 一份涵盖大部分Java程序员所需要掌握的核心知识。
Stars: ✭ 28,668 (+4868.46%)
Mutual labels: redis
Newlife.redis
高性能Redis客户端,支持.NETCore/.NET4.0/.NET4.5,为大数据与消息队列而特别优化,线上单应用日均100亿调用量
Stars: ✭ 552 (-4.33%)
Mutual labels: redis
Netdiscovery
NetDiscovery 是一款基于 Vert.x、RxJava 2 等框架实现的通用爬虫框架/中间件。
Stars: ✭ 573 (-0.69%)
Mutual labels: redis
Centrifugo
Scalable real-time messaging server in a language-agnostic way. Set up once and forever.
Stars: ✭ 5,649 (+879.03%)
Mutual labels: redis
Spring Boot Klock Starter
基于redis的分布式锁组件,简单方便快捷接入项目,使项目拥有分布式锁能力
Stars: ✭ 546 (-5.37%)
Mutual labels: redis
Java Study
java-study 是本人学习Java过程中记录的一些代码!从Java基础的数据类型、jdk1.8的Lambda、Stream和日期的使用、 IO流、数据集合、多线程使用、并发编程、23种设计模式示例代码、常用的工具类, 以及一些常用框架,netty、mina、springboot、kafka、storm、zookeeper、redis、elasticsearch、hbase、hive等等。
Stars: ✭ 571 (-1.04%)
Mutual labels: redis
Taskq
Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends
Stars: ✭ 555 (-3.81%)
Mutual labels: redis
Docker Alpine
Docker containers running Alpine Linux and s6 for process management. Solid, reliable containers.
Stars: ✭ 574 (-0.52%)
Mutual labels: redis
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+908.84%)
Mutual labels: redis
Gin Boilerplate
The fastest way to deploy a restful api's with Gin Framework with a structured project that defaults to PostgreSQL database and JWT authentication middleware stored in Redis
Stars: ✭ 559 (-3.12%)
Mutual labels: redis
distributed-redis-tool
This is a simple distributed tools based on Redis.
Distributed lock
Distributed limiting
Visit this website for more information.
ChangeLog
v1.0.5
- Fixed #9.
- Optimization RedisCluster.
v1.0.4
- Upgrade distributed lock API.
- Support connection pool.
- Improve distributed lock performance ⚡️.
v1.0.3
- Upgrade API.
- Add Anation.
- Improve performance ⚡️ .
Contact
Mail: [email protected]
Distributed lock
Features
- [x] High performance.
- [x] No deadlock.
- [x] Support Redis cluster, single.
- [x] Non-blocking lock.
- [x] blocking lock.
- [x] Support connection pool.
- [x] Suppport Spring4.x+.
Quick start
maven dependency:
<dependency>
<groupId>top.crossoverjie.opensource</groupId>
<artifactId>distributed-redis-tool</artifactId>
<version>1.0.4</version>
</dependency>
Set bean:
@Configuration
public class RedisLockConfig {
private Logger logger = LoggerFactory.getLogger(RedisLockConfig.class);
@Autowired
private JedisConnectionFactory jedisConnectionFactory;
@Bean
public RedisLock build() {
RedisLock redisLock = new RedisLock.Builder(jedisConnectionFactory,RedisToolsConstant.SINGLE)
.lockPrefix("lock_")
.sleepTime(100)
.build();
return redisLock;
}
}
Non-blocking lock:
@Autowired
private RedisLock redisLock ;
public void use() {
String key = "key";
String request = UUID.randomUUID().toString();
try {
boolean locktest = redisLock.tryLock(key, request);
if (!locktest) {
System.out.println("locked error");
return;
}
//do something
} finally {
redisLock.unlock(key,request) ;
}
}
Blocking lock
redisLock.lock(String key, String request);
Blocking lock, Custom block time
redisLock.lock(String key, String request,int blockTime);
Distributed limiting
Features
- [x] High performance.
- [x] native API.
- [x] Annation API.
- [x] Support Redis cluster, single.
- [x] Suppport Spring4.x+
Quick start
maven dependency:
<dependency>
<groupId>top.crossoverjie.opensource</groupId>
<artifactId>distributed-redis-tool</artifactId>
<version>1.0.4</version>
</dependency>
- Set bean:
@Configuration
public class RedisLimitConfig {
private Logger logger = LoggerFactory.getLogger(RedisLimitConfig.class);
@Value("${redis.limit}")
private int limit;
@Autowired
private JedisConnectionFactory jedisConnectionFactory;
@Bean
public RedisLimit build() {
RedisLimit redisLimit = new RedisLimit.Builder(jedisConnectionFactory, RedisToolsConstant.SINGLE)
.limit(limit)
.build();
return redisLimit;
}
}
- Scan
com.crossoverjie.distributed.interceptpackage.
@ComponentScan(value = "com.crossoverjie.distributed.intercept")
Native API:
boolean limit = redisLimit.limit();
if (!limit){
res.setCode(StatusEnum.REQUEST_LIMIT.getCode());
res.setMessage(StatusEnum.REQUEST_LIMIT.getMessage());
return res ;
}
Other apis:
@ControllerLimit
@ControllerLimit
public BaseResponse<OrderNoResVO> getOrderNoLimit(@RequestBody OrderNoReqVO orderNoReq) {
BaseResponse<OrderNoResVO> res = new BaseResponse();
res.setReqNo(orderNoReq.getReqNo());
if (null == orderNoReq.getAppId()){
throw new SBCException(StatusEnum.FAIL);
}
OrderNoResVO orderNoRes = new OrderNoResVO() ;
orderNoRes.setOrderId(DateUtil.getLongTime());
res.setCode(StatusEnum.SUCCESS.getCode());
res.setMessage(StatusEnum.SUCCESS.getMessage());
res.setDataBody(orderNoRes);
return res ;
}
Used for @RequestMapping.
@SpringControllerLimit
If you are using native Spring:
@SpringControllerLimit(errorCode = 200,errorMsg = "request has limited")
@RequestMapping("/createOptimisticLimitOrderByRedis/{sid}")
@ResponseBody
public String createOptimisticLimitOrderByRedis(@PathVariable int sid) {
logger.info("sid=[{}]", sid);
int id = 0;
try {
id = orderService.createOptimisticOrderUseRedis(sid);
} catch (Exception e) {
logger.error("Exception",e);
}
return String.valueOf(id);
}
Spring xml:
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.crossoverjie.distributed.intercept.SpringMVCIntercept"/>
</mvc:interceptor>
</mvc:interceptors>
@CommonLimit
@CommonLimit
public void anyMethod(){}
It can be used for any methods.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].

