Tabnine Logo
RedissonClient
Code IndexAdd Tabnine to your IDE (free)

How to use
RedissonClient
in
org.redisson.api

Best Java code snippets using org.redisson.api.RedissonClient (Showing top 20 results out of 540)

Refine searchRefine arrow

  • Redisson
origin: redisson/redisson

protected void shutdownRedisson() {
  if (redisson != null) {
    redisson.shutdown();
  }
}
origin: redisson/redisson

public RMap<String, Object> getMap(String sessionId) {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  String name = keyPrefix + separator + "redisson:tomcat_session:" + sessionId;
  return redisson.getMap(name, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
}
origin: redisson/redisson

public RedissonPriorityQueue(CommandExecutor commandExecutor, String name, RedissonClient redisson) {
  super(commandExecutor, name, redisson);
  this.commandExecutor = commandExecutor;
  comparatorHolder = redisson.getBucket(getComparatorKeyName(), StringCodec.INSTANCE);
  lock = redisson.getLock("redisson_sortedset_lock:{" + getName() + "}");
  
  loadComparator();
}
origin: redisson/redisson

protected RedissonSortedSet(CommandExecutor commandExecutor, String name, RedissonClient redisson) {
  super(commandExecutor, name);
  this.commandExecutor = commandExecutor;
  this.redisson = redisson;
  comparatorHolder = redisson.getBucket(getComparatorKeyName(), StringCodec.INSTANCE);
  lock = redisson.getLock("redisson_sortedset_lock:{" + getName() + "}");
  list = (RedissonList<V>) redisson.getList(getName());
  
  loadComparator();
}
origin: redisson/redisson-examples

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();
}

origin: redisson/redisson-examples

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();
}

origin: redisson/redisson-examples

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();
  }
}

origin: redisson/redisson-examples

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();
}

origin: redisson/redisson-examples

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();
}

origin: redisson/redisson

public RedissonSession(String keyPrefix) {
  this.delegate = new MapSession();
  map = redisson.getMap(keyPrefix + delegate.getId(), new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
  principalName = resolvePrincipal(delegate);
  Map<String, Object> newMap = new HashMap<String, Object>(3);
  newMap.put("session:creationTime", delegate.getCreationTime());
  newMap.put("session:lastAccessedTime", delegate.getLastAccessedTime());
  newMap.put("session:maxInactiveInterval", delegate.getMaxInactiveIntervalInSeconds());
  map.putAll(newMap);
  updateExpiration();
  
  String channelName = getEventsChannelName(delegate.getId());
  RTopic topic = redisson.getTopic(channelName, StringCodec.INSTANCE);
  topic.publish(delegate.getId());
}
origin: redisson/redisson

public RTopic getTopic() {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  final String name = keyPrefix + separator + "redisson:tomcat_session_updates:" + ((Context) getContainer()).getName();
  return redisson.getTopic(name);
}

origin: redisson/redisson

protected RMap<Object, Object> getMap(String name, CacheConfig config) {
  if (codec != null) {
    return redisson.getMap(name, codec);
  }
  return redisson.getMap(name);
}
origin: redisson/redisson

@Override
public void run() {
  Codec codec;
  try {
    codec = (Codec) objectCodecClass.getConstructor().newInstance();
  } catch (Exception e) {
    throw new IllegalStateException(e);
  }
  
  Injector.inject(mapper, redisson);
  RCollector<KOut, VOut> collector = new Collector<KOut, VOut>(codec, redisson, collectorMapName, workersAmount, timeout);
  for (String objectName : objectNames) {
    RMap<KIn, VIn> map = null;
    if (RMapCache.class.isAssignableFrom(objectClass)) {
      map = redisson.getMapCache(objectName, codec);
    } else {
      map = redisson.getMap(objectName, codec);
    }
    
    for (Entry<KIn, VIn> entry : map.entrySet()) {
      if (Thread.currentThread().isInterrupted()) {
        return;
      }
      
      mapper.map(entry.getKey(), entry.getValue(), collector);
    }
  }
}
origin: redisson/redisson

@Override
public RedisSentinelConnection getSentinelConnection() {
  if (!redisson.getConfig().isSentinelConfig()) {
    throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode");
  }
  
  SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager());
  for (RedisClient client : manager.getSentinels()) {
    org.redisson.client.RedisConnection connection = client.connect();
    try {
      String res = connection.sync(RedisCommands.PING);
      if ("pong".equalsIgnoreCase(res)) {
        return new RedissonSentinelConnection(connection);
      }
    } catch (Exception e) {
      log.warn("Can't connect to " + client, e);
      connection.closeAsync();
    }
  }
  
  throw new InvalidDataAccessResourceUsageException("Sentinels are not found");
}
origin: redisson/redisson

private Object executeCollator() throws ExecutionException, Exception {
  if (collator == null) {
    if (timeout > 0) {
      redisson.getMap(resultMapName).clearExpire();
    }
    return null;
  }
  
  Callable<Object> collatorTask = new CollatorTask<KOut, VOut, Object>(redisson, collator, resultMapName, objectCodecClass);
  long timeSpent = System.currentTimeMillis() - startTime;
  if (isTimeoutExpired(timeSpent)) {
    throw new MapReduceTimeoutException();
  }
  if (timeout > 0) {
    ExecutorService executor = ((Redisson) redisson).getConnectionManager().getExecutor();
    java.util.concurrent.Future<?> collatorFuture = executor.submit(collatorTask);
    try {
      return collatorFuture.get(timeout - timeSpent, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      return null;
    } catch (TimeoutException e) {
      collatorFuture.cancel(true);
      throw new MapReduceTimeoutException();
    }
  } else {
    return collatorTask.call();
  }
}
origin: redisson/redisson

protected RMapCache<Object, Object> getMapCache(String name, CacheConfig config) {
  if (codec != null) {
    return redisson.getMapCache(name, codec);
  }
  return redisson.getMapCache(name);
}
origin: redisson/redisson

@Override
public Long resolve(Class value, RId id, String idFieldName, RedissonClient redisson) {
  return redisson.getAtomicLong(this.getClass().getCanonicalName()
      + "{" + value.getCanonicalName() + "}:" + idFieldName)
      .incrementAndGet();
}
origin: redisson/redisson

@Override
public CommandAsyncExecutor enableRedissonReferenceSupport(RedissonClient redisson) {
  if (redisson != null) {
    this.redisson = redisson;
    enableRedissonReferenceSupport(redisson.getConfig());
    this.redissonReactive = null;
    this.redissonRx = null;
  }
  return this;
}
origin: huangjian888/jeeweb-mybatis-springboot

@Override
public final String type(final String key) {
  RType type = redissonClient.getKeys().getType(key);
  if (type == null) {
    return null;
  }
  return type.getClass().getName();
}
origin: redisson/redisson

private void awaitResultAsync(final RemoteInvocationOptions optionsCopy, final RemotePromise<Object> result,
    final String ackName, final RFuture<RRemoteServiceResponse> responseFuture) {
  RFuture<Boolean> deleteFuture = redisson.getBucket(ackName).deleteAsync();
  deleteFuture.addListener(new FutureListener<Boolean>() {
    @Override
    public void operationComplete(Future<Boolean> future) throws Exception {
      if (!future.isSuccess()) {
        result.tryFailure(future.cause());
        return;
      }
      awaitResultAsync(optionsCopy, result, responseFuture);
    }
  });
}

org.redisson.apiRedissonClient

Javadoc

Main Redisson interface for access to all redisson objects with sync/async interface.

Most used methods

  • shutdown
    Shuts down Redisson instance but NOT Redis server Shutdown ensures that no tasks are submitted for '
  • getMap
    Returns map instance by name using provided codec for both map keys and values.
  • getLock
    Returns lock instance by name. Implements a non-fair locking so doesn't guarantees an acquire order
  • getTopic
    Returns topic instance by name using provided codec for messages.
  • getBucket
    Returns object holder instance by name using provided codec for object.
  • getConfig
    Allows to get configuration provided during Redisson instance creation. Further changes on this obje
  • getMapCache
    Returns map-based cache instance by name using provided codec for both cache keys and values. Suppor
  • getAtomicLong
    Returns atomicLong instance by name.
  • getKeys
    Returns interface with methods for Redis keys. Each of Redis/Redisson object associated with own key
  • getScript
    Returns script operations object using provided codec.
  • getSemaphore
    Returns semaphore instance by name
  • getSet
    Returns set instance by name using provided codec for set objects.
  • getSemaphore,
  • getSet,
  • getBlockingQueue,
  • getList,
  • getScoredSortedSet,
  • getExecutorService,
  • getFairLock,
  • getQueue,
  • getReadWriteLock,
  • getListMultimap

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Collectors (java.util.stream)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now