required: JDK1.5+
- ①强大的泛型支持,实现了任意java对象简单存\取
- ②增强
缓存
接口:支持防穿透设计,以及本地缓存同步更新 - ③提供多种
分布式锁
,分布式队列
支持 - ④个性化的redis源配置支持
Normal Style
IRedisMap<Integer, User> cache = Redis.use("redisSourceName");
User user = new User();
cache.put(1001,user);
User redisUser = cache.get(1001);
Fluent Style
IRedisMap<Integer, User> cache = Redis.create().setServiceName("redisSourceName").build();
User user = new User();
cache.put(1001,user);
User redisUser = cache.get(1001);
Normal Style
Lock lock = RedisLock.useSimpleRedisLock("simpleLock", "redisSourceName");
try {
lock.lock();
lock.isLocking();
} finally {
lock.unlock();
}
Fluent Style
Lock lock = RedisLock.create().setService("redisSourceName").setLockName("simpleLock").useSimpleRedisLock();
try {
lock.lock();
lock.isLocking();
} finally {
lock.unlock();
}
Normal Style
Queue<Task> queue = RedisQueue.useSimpleFifoQueue("simpleQueue","redisSourceName");
queue.enqueue(task1,task2,task3);
Task task = queue.dequeue();
Fluent Style
Queue<Task> queue = RedisQueue.create().setService("redisSourceName").setQueueName("simpleQueue").useSimpleFifoQueue();
queue.enqueue(task1,task2,task3);
Task task = queue.dequeue();
service.names=redisSourceName,redisSourceName1,...
redisSourceName.ip = 127.0.0.1
redisSourceName.port = 6379
redisSourceName.password=password
redisSourceName.ip-port-password = 127.0.0.1:6379?password
redisSourceName1.is.cluster = true
redisSourceName1.sentinel.master.name = masterName
redisSourceName1.sentinel.hosts = 127.0.0.1:6379;127.0.0.1:6389;127.0.0.1:6379;127.0.0.1:6399
redisSourceName1.password = password
redisSourceName.open.local.cache = true
redisSourceName[.read].timeoutInMillis = 10000
redisSourceName[.write].timeoutInMillis = 10000
redisSourceName[.read].maxTotal = 8
redisSourceName[.write].maxTotal = 8
redisSourceName[.read].maxIdle = 20
redisSourceName[.write].maxIdle = 20
redisSourceName[.read].maxWait = 2000
redisSourceName[.write].maxWait = 2000
redisSourceName[.read].testOnBorrow = true
redisSourceName[.write].testOnBorrow = true
redisSourceName[.read].testOnReturn = false
redisSourceName[.write].testOnReturn = false
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>