Refine search
/** * Creates factory with default Redisson configuration */ public RedissonConnectionFactory() { this(Redisson.create()); }
protected void scheduleRetryTimeRenewal(final String requestId) { ((Redisson)redisson).getConnectionManager().newTimeout(new TimerTask() { @Override public void run(Timeout timeout) throws Exception { renewRetryTime(requestId); } }, 5, TimeUnit.SECONDS); }
public RedissonConnection(RedissonClient redisson) { super(); this.redisson = (Redisson) redisson; executorService = (CommandAsyncService) this.redisson.getCommandExecutor(); }
public RedissonSortedSet(Codec codec, CommandExecutor commandExecutor, String name, Redisson redisson) { super(codec, commandExecutor, name); this.commandExecutor = commandExecutor; comparatorHolder = redisson.getBucket(getComparatorKeyName(), StringCodec.INSTANCE); lock = redisson.getLock("redisson_sortedset_lock:{" + getName() + "}"); list = (RedissonList<V>) redisson.getList(getName(), codec); loadComparator(); }
ConcurrentMap<URI, CacheManager> oldValue = managers.putIfAbsent(classLoader, value); if (oldValue != null) { value = oldValue; CacheManager manager = value.get(uri); if (manager != null) { return manager; redisson = (Redisson) Redisson.create(config); CacheManager oldManager = value.putIfAbsent(uri, manager); if (oldManager != null) { if (redisson != null) { redisson.shutdown();
RedissonConfiguration<K, V> rc = (RedissonConfiguration<K, V>) configuration; if (rc.getConfig() != null) { cacheRedisson = (Redisson) Redisson.create(rc.getConfig()); hasOwnRedisson = true; } else { JCache<?, ?> oldCache = caches.putIfAbsent(cacheName, cache); if (oldCache != null) { throw new CacheException("Cache " + cacheName + " already exists");
public static void main(String[] args) throws InterruptedException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); CountDownLatch latch = new CountDownLatch(1); RTopic topic = redisson.getTopic("topic2"); topic.addListener(String.class, new MessageListener<String>() { @Override public void onMessage(CharSequence channel, String msg) { latch.countDown(); } }); topic.publish("msg"); latch.await(); redisson.shutdown(); }
public static void main(String[] args) throws InterruptedException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RLock lock = redisson.getLock("lock"); lock.lock(2, TimeUnit.SECONDS); Thread t = new Thread() { public void run() { RLock lock1 = redisson.getLock("lock"); lock1.lock(); lock1.unlock(); }; }; t.start(); t.join(); lock.unlock(); redisson.shutdown(); }
public static void main(String[] args) { RedissonClient redisson = Redisson.create(); RBucket<String> bucket = redisson.getBucket("test"); bucket.set("123"); boolean isUpdated = bucket.compareAndSet("123", "4934"); String prevObject = bucket.getAndSet("321"); boolean isSet = bucket.trySet("901"); long objectSize = bucket.size(); // set with expiration bucket.set("value", 10, TimeUnit.SECONDS); boolean isNewSet = bucket.trySet("nextValue", 10, TimeUnit.SECONDS); redisson.shutdown(); }
redisson = Redisson.create(config); mapReduceWorkers = Runtime.getRuntime().availableProcessors(); redisson.getExecutorService(RExecutorService.MAPREDUCE_NAME).registerWorkers(mapReduceWorkers); log.info("{} map reduce worker(s) registered", mapReduceWorkers); String name = entry.getKey(); int workers = entry.getValue(); redisson.getExecutorService(name).registerWorkers(workers); log.info("{} worker(s) for '{}' ExecutorService registered", workers, name);
public static void main(String[] args) throws InterruptedException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RSemaphore s = redisson.getSemaphore("test"); s.trySetPermits(5); s.acquire(3); Thread t = new Thread() { @Override public void run() { RSemaphore s = redisson.getSemaphore("test"); s.release(); s.release(); } }; t.start(); s.acquire(4); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient server = Redisson.create(); RedissonClient client = Redisson.create(); try { server.getRemoteService().register(RemoteInterface.class, new RemoteImpl()); RemoteInterface service = client.getRemoteService().get(RemoteInterface.class); service.myMethod(21L); } finally { client.shutdown(); server.shutdown(); } }
public static void main(String[] args) throws InterruptedException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); final RReadWriteLock lock = redisson.getReadWriteLock("lock"); lock.writeLock().tryLock(); Thread t = new Thread() { public void run() { RLock r = lock.readLock(); r.lock(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } r.unlock(); }; }; t.start(); t.join(); lock.writeLock().unlock(); t.join(); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RSetCache<String> setCache = redisson.getSetCache("mySet"); // with ttl = 20 seconds boolean isAdded = setCache.add("1", 20, TimeUnit.SECONDS); // store value permanently setCache.add("2"); setCache.contains("1"); for (String string : setCache) { // iteration through bulk loaded values } boolean removedValue = setCache.remove("1"); setCache.removeAll(Arrays.asList("1", "2", "3")); setCache.containsAll(Arrays.asList("4", "1", "0")); RSet<String> secondsSet = redisson.getSet("mySecondsSet"); secondsSet.add("4"); secondsSet.add("5"); Set<String> allValues = secondsSet.readAll(); redisson.shutdown(); }
public static void main(String[] args) throws IOException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RBinaryStream stream = redisson.getBinaryStream("myStream"); byte[] values = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; stream.trySet(values); stream.set(values); InputStream is = stream.getInputStream(); StringBuilder sb = new StringBuilder(); int ch; while((ch = is.read()) != -1) { sb.append((char)ch); } String str = sb.toString(); OutputStream os = stream.getOutputStream(); for (int i = 0; i < values.length; i++) { byte c = values[i]; os.write(c); } redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RAtomicLong atomicLong = redisson.getAtomicLong("myLong"); atomicLong.getAndDecrement(); atomicLong.getAndIncrement(); atomicLong.addAndGet(10L); atomicLong.compareAndSet(29, 412); atomicLong.decrementAndGet(); atomicLong.incrementAndGet(); atomicLong.getAndAdd(302); atomicLong.getAndDecrement(); atomicLong.getAndIncrement(); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RSortedSet<String> sortedSet = redisson.getSortedSet("mySortedSet"); sortedSet.add("1"); sortedSet.add("2"); sortedSet.add("3"); for (String string : sortedSet) { // iteration through bulk loaded values } String firstValue = sortedSet.first(); String lastValue = sortedSet.last(); boolean removedValue = sortedSet.remove("1"); sortedSet.removeAll(Arrays.asList("1", "2", "3")); sortedSet.containsAll(Arrays.asList("4", "1", "0")); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RAtomicDouble atomicDouble = redisson.getAtomicDouble("myDouble"); atomicDouble.getAndDecrement(); atomicDouble.getAndIncrement(); atomicDouble.addAndGet(10.323); atomicDouble.compareAndSet(29.4, 412.91); atomicDouble.decrementAndGet(); atomicDouble.incrementAndGet(); atomicDouble.getAndAdd(302.00); atomicDouble.getAndDecrement(); atomicDouble.getAndIncrement(); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RHyperLogLog<String> hyperLogLog = redisson.getHyperLogLog("hyperLogLog"); hyperLogLog.add("1"); hyperLogLog.add("2"); hyperLogLog.add("3"); hyperLogLog.addAll(Arrays.asList("10", "20", "30")); RHyperLogLog<String> hyperLogLog1 = redisson.getHyperLogLog("hyperLogLog1"); hyperLogLog1.add("4"); hyperLogLog1.add("5"); hyperLogLog1.add("6"); RHyperLogLog<String> hyperLogLog2 = redisson.getHyperLogLog("hyperLogLog2"); hyperLogLog1.add("4"); hyperLogLog1.add("5"); hyperLogLog1.add("6"); hyperLogLog2.mergeWith(hyperLogLog1.getName()); hyperLogLog2.countWith(hyperLogLog1.getName()); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RGeo<String> geo = redisson.getGeo("myGeo"); GeoEntry entry = new GeoEntry(13.361389, 38.115556, "Palermo"); geo.add(entry); geo.add(15.087269, 37.502669, "Catania"); Double dist = geo.dist("Palermo", "Catania", GeoUnit.METERS); Map<String, GeoPosition> pos = geo.pos("Palermo", "Catania"); List<String> cities = geo.radius(15, 37, 200, GeoUnit.KILOMETERS); List<String> allNearCities = geo.radius("Palermo", 10, GeoUnit.KILOMETERS); Map<String, Double> citiesWithDistance = geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS); Map<String, Double> allNearCitiesDistance = geo.radiusWithDistance("Palermo", 10, GeoUnit.KILOMETERS); Map<String, GeoPosition> citiesWithPosition = geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS); Map<String, GeoPosition> allNearCitiesPosition = geo.radiusWithPosition("Palermo", 10, GeoUnit.KILOMETERS); redisson.shutdown(); }