You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
redisson/README.md

259 lines
7.6 KiB
Markdown

11 years ago
##Redisson - distributed and scalable Java data structures on top of Redis server. Advanced Redis client
11 years ago
11 years ago
Use familiar Java data structures with power of [Redis](http://redis.io).
11 years ago
Based on patched version of [lettuce](https://github.com/wg/lettuce) [Redis](http://redis.io) client and [Netty 4](http://netty.io) framework.
11 years ago
Redis 2.4+ and JDK 1.6+ compatible
11 years ago
Licensed under the Apache License 2.0.
Features
================================
11 years ago
* Sentinel servers mode:
11 years ago
1. read and write data using single server
2. automatic master and slave servers info gathering
3. automatic new master server info gathering
4. automatic new slave servers info gathering
5. automatic slave servers offline/online info gathering
11 years ago
* Master with Slave servers mode: read using slave servers, write using master server
* Single server mode: read and write data using single server
11 years ago
* Distributed implementation of `java.util.List`
* Distributed implementation of `java.util.Set`
11 years ago
* Distributed implementation of `java.util.SortedSet`
11 years ago
* Distributed implementation of `java.util.Queue`
11 years ago
* Distributed implementation of `java.util.Deque`
11 years ago
* Distributed implementation of `java.util.Map`
* Distributed implementation of `java.util.concurrent.ConcurrentMap`
* Distributed implementation of reentrant `java.util.concurrent.locks.Lock`
* Distributed alternative to the `java.util.concurrent.atomic.AtomicLong`
* Distributed alternative to the `java.util.concurrent.CountDownLatch`
11 years ago
* Distributed publish/subscribe messaging via `org.redisson.core.RTopic`
* Distributed HyperLogLog via `org.redisson.core.RHyperLogLog`
11 years ago
* Thread-safe implementation
11 years ago
* Supports OSGi
11 years ago
* With over 110 unit tests
11 years ago
Recent Releases
================================
####Please Note: trunk is current development branch.
11 years ago
####17-June-2014 - version 1.1.1 released
Feature - sentinel servers support
Fixed - connection leak in `RTopic`
Fixed - setted password not used in single server connection
11 years ago
####07-June-2014 - version 1.1.0 released
11 years ago
Feature - master/slave connection management
11 years ago
Feature - simple set/get object support via `org.redisson.core.RBucket`
Feature - hyperloglog support via `org.redisson.core.RHyperLogLog`
Feature - new methods `getAsync`, `putAsync` and `removeAsync` added to `org.redisson.core.RMap`
Feature - new method `publishAsync` added to `org.redisson.core.RTopic`
Feature - [Kryo](https://github.com/EsotericSoftware/kryo) codec added (thanks to mathieucarbou)
11 years ago
__Breaking api change__ - `org.redisson.Config` model changed
11 years ago
Fixed - score calucaltion algorithm used in `RSortedSet`.
11 years ago
Fixed - `RMap.put` & `RMap.remove` result consistency fixed.
Fixed - `RTopic.publish` now returns the number of clients that received the message
Fixed - reconnection handling (thanks to renzihui)
Improvement - `org.redisson.core.RTopic` now use lazy apporach for subscribe/unsubscribe
11 years ago
####04-May-2014 - version 1.0.4 released
Feature - distributed implementation of `java.util.Deque`
Feature - some objects implements `org.redisson.core.RExpirable`
Fixed - JsonJacksonCodec lazy init
11 years ago
####26-Mar-2014 - version 1.0.3 released
Fixed - RedissonAtomicLong state format
Fixed - Long serialization in JsonJacksonCodec
11 years ago
####05-Feb-2014 - version 1.0.2 released
11 years ago
Feature - distributed implementation of `java.util.SortedSet`
Fixed - OSGi compability
11 years ago
####17-Jan-2014 - version 1.0.1 released
11 years ago
Improvement - forceUnlock, isLocked, isHeldByCurrentThread and getHoldCount methods added to RLock
Feature - connection load balancer to use multiple Redis servers
Feature - published in maven central repo
11 years ago
11 years ago
####11-Jan-2014 - version 1.0.0 released
First stable release.
11 years ago
### Maven
Include the following to your dependency list:
11 years ago
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
11 years ago
<version>1.1.1</version>
11 years ago
</dependency>
11 years ago
Usage examples
================================
####Simple config example
// connects to Redis server 127.0.0.1:6379 by default
Redisson redisson = Redisson.create();
...
redisson.shutdown();
11 years ago
or with initialization by Config object for single server connection
11 years ago
Config config = new Config();
11 years ago
config.useSingleServer()
11 years ago
.setAddress("127.0.0.1:6379")
11 years ago
.setConnectionPoolSize(10);
11 years ago
11 years ago
Redisson redisson = Redisson.create(config);
11 years ago
or master/slave servers connection
11 years ago
Config config = new Config();
config.useMasterSlaveConnection()
.setMasterAddress("127.0.0.1:6379")
11 years ago
.addSlaveAddress("127.0.0.1:6389", "127.0.0.1:6332", "127.0.0.1:6419")
11 years ago
.addSlaveAddress("127.0.0.1:6399");
11 years ago
Redisson redisson = Redisson.create(config);
11 years ago
for sentinel servers connection
Config config = new Config();
config.useSentinelConnection()
.setMasterName("mymaster")
.addSentinelAddress("127.0.0.1:26389", "127.0.0.1:26379")
.addSentinelAddress("127.0.0.1:26319";
Redisson redisson = Redisson.create(config);
11 years ago
11 years ago
####Distributed Map example
11 years ago
Redisson redisson = Redisson.create();
ConcurrentMap<String, SomeObject> map = redisson.getMap("anyMap");
map.put("123", new SomeObject());
map.putIfAbsent("323", new SomeObject());
map.remove("123");
...
redisson.shutdown();
11 years ago
####Distributed Set example
11 years ago
Redisson redisson = Redisson.create();
Set<SomeObject> set = redisson.getSet("anySet");
set.add(new SomeObject());
set.remove(new SomeObject());
...
redisson.shutdown();
11 years ago
####Distributed List example
11 years ago
Redisson redisson = Redisson.create();
List<SomeObject> list = redisson.getList("anyList");
list.add(new SomeObject());
list.get(0);
list.remove(new SomeObject());
...
redisson.shutdown();
11 years ago
####Distributed Queue example
11 years ago
Redisson redisson = Redisson.create();
Queue<SomeObject> queue = redisson.getQueue("anyQueue");
queue.add(new SomeObject());
queue.peek();
queue.pool();
...
redisson.shutdown();
11 years ago
####Distributed Lock example
11 years ago
Redisson redisson = Redisson.create();
Lock lock = redisson.getLock("anyLock");
lock.lock();
lock.unlock();
// same as
redisson.getLock("anyLock").lock();
...
redisson.getLock("anyLock").unlock();
...
redisson.shutdown();
####Distributed AtomicLong example
Redisson redisson = Redisson.create();
RAtomicLong atomicLong = redisson.getAtomicLong("anyAtomicLong");
atomicLong.set(3);
atomicLong.incrementAndGet();
atomicLong.get();
...
redisson.shutdown();
####Distributed CountDownLatch example
Redisson redisson = Redisson.create();
RCountDownLatch latch = redisson.getCountDownLatch("anyCountDownLatch");
latch.trySetCount(1);
latch.await();
// in other thread or other JVM
RCountDownLatch latch = redisson.getCountDownLatch("anyCountDownLatch");
latch.countDown();
...
redisson.shutdown();
11 years ago
####Distributed Topic example
Redisson redisson = Redisson.create();
RTopic<SomeObject> topic = redisson.getTopic("anyTopic");
topic.addListener(new MessageListener<SomeObject>() {
public void onMessage(SomeObject message) {
...
}
});
// in other thread or other JVM
RTopic<SomeObject> topic = redisson.getTopic("anyTopic");
topic.publish(new SomeObject());
...
redisson.shutdown();