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

How to use
getAtomicLong
method
in
org.redisson.api.RedissonClient

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

origin: redisson/redisson

public RedissonLongAdder(CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) {
  super(connectionManager, name, redisson);
  
  atomicLong = redisson.getAtomicLong(getName());
}
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 Long resolve(Class value, RId id, String idFieldName, RedissonClient redisson) {
  return redisson.getAtomicLong(this.getClass().getCanonicalName()
      + "{" + value.getCanonicalName() + "}:" + idFieldName)
      .incrementAndGet();
}
origin: redisson/redisson

public RedissonLongAdder(CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) {
  super(connectionManager, name, redisson);
  
  atomicLong = redisson.getAtomicLong(getName());
}
origin: hs-web/hsweb-framework

  @Override
  protected Counter createCount(String name) {
    return new RedissonCounter(redisson.getAtomicLong(name));
  }
}
origin: yangwenjie88/delay-queue

/**
 * Get atomic long r atomic long.
 *
 * @param objectName the object name
 * @return the r atomic long
 */
public static RAtomicLong getAtomicLong(String objectName){
  return redissonClient.getAtomicLong(objectName);
}
origin: org.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: org.redisson/redisson

public RedissonLongAdder(CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) {
  super(connectionManager, name, redisson);
  
  atomicLong = redisson.getAtomicLong(getName());
}
origin: justlive1/earth-frost

@Override
public void enter(String loggerId, String type) {
 // 运行中 ++
 redissonClient.getAtomicLong(JobConfig.STAT_TOTAL_RUNNING).incrementAndGet();
 redissonClient.getAtomicLong(String.format(JobConfig.STAT_TOTAL_TYPE, type)).incrementAndGet();
}
origin: huangjian888/jeeweb-mybatis-springboot

@Override
public Long incr(String key) {
  return redissonClient.getAtomicLong(key).incrementAndGet();
}
origin: xuminwlt/j360-dubbo-app-all

/**
 * 回写补偿数据
 * @param id
 * @param column
 * @param key
 * @param redissonClient
 * @param baseDao
 */
public static void writeCompensateCount(Long id, String column,String key, RedissonClient redissonClient,BaseDao baseDao) {
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(key);
  if (retryCountToCache(id, column, key, 0, rCacheLong, redissonClient, baseDao)) {
    //回写DB加减1
    //baseDao.updateCountValue(column, id);
  }
}
origin: justlive1/earth-frost

 @Override
 public void leave(String loggerId, String type, boolean success) {
  // 运行中 --
  redissonClient.getAtomicLong(JobConfig.STAT_TOTAL_RUNNING).decrementAndGet();
  // 每日统计
  String date = DateTimeFormatter.ISO_LOCAL_DATE.format(ZonedDateTime.now());
  String key;
  if (success) {
   key = String.format(JobConfig.STAT_DATE_TYPE_SUCCESS, date, type);
  } else {
   key = String.format(JobConfig.STAT_DATE_TYPE_FAIL, date, type);
  }
  redissonClient.getAtomicLong(key).incrementAndGet();

  removeOldestLogger(loggerId);
 }
}
origin: xuminwlt/j360-dubbo-app-all

public static Long readCount(Long id, String column, String key,RedissonClient redissonClient,BaseDao baseDao) {
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(key);
  RAtomicLong rResultLong = getSourceToCacheOnce(id, column, key, rCacheLong, redissonClient, baseDao);
  if (Objects.isNull(rResultLong)) {
    return 0L;
  }
  return rResultLong.get();
}
origin: xuminwlt/j360-dubbo-app-all

/**
 * 读取count
 * @param id
 * @param cacheModelEnum
 * @return
 */
public Long readBizCount(Long id, CacheModelEnum cacheModelEnum) {
  String redisKey = String.format(cacheModelEnum.getRedisKey(), id);
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(redisKey);
  RAtomicLong rResultLong = getSourceToCacheOnce(id, cacheModelEnum, rCacheLong);
  if (Objects.isNull(rResultLong)) {
    return 0L;
  }
  rCacheLong.expireAsync(AppConfig.COMMON_COUNT_CACHE_DAYS, TimeUnit.DAYS);
  return rResultLong.get();
}
origin: xuminwlt/j360-dubbo-app-all

public static Long writeCount(DefaultAsyncEventBus eventBus,Long id, String column,String key, RedissonClient redissonClient,BaseDao baseDao) {
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(key);
  RAtomicLong rResultLong = getSourceToCacheOnce(id, column, key, rCacheLong, redissonClient, baseDao);
  if (Objects.isNull(rResultLong)) {
    //TODO 进入MQ模式
    //mqProducter.send(message);
    return 0L;
  }
  long cacheCount = rResultLong.incrementAndGet();
  //进入步长模式,调用Event
  CacheSyncEvent event = new CacheSyncEvent();
  event.setCacheValue(cacheCount);
  eventBus.post(event);
  return cacheCount;
}
origin: xuminwlt/j360-dubbo-app-all

private boolean checkStepCondition(CacheSyncEvent cacheSyncEvent, RAtomicLong rCacheLong) {
  //
  RAtomicLong rRanageAtomicLong = redissonClient.getAtomicLong(rCacheLong.getName() + "_range");
  long ttl = rRanageAtomicLong.remainTimeToLive();
  long value = rRanageAtomicLong.get();
  if (ttl < AppConfig.COMMON_COUNT_RANGE_DAYS * 24 * 3600 * 1000 - AppConfig.CACHE_TIME_RANGE) {
    rRanageAtomicLong.expire(AppConfig.COMMON_COUNT_RANGE_DAYS, TimeUnit.DAYS);
    return true;
  }
  if (cacheSyncEvent.getCacheValue()-value >= AppConfig.CACHE_COUNT_RANGE) {
    rRanageAtomicLong.set(cacheSyncEvent.getCacheValue());
    return true;
  }
  return false;
  //return true;
}
origin: xuminwlt/j360-dubbo-app-all

/**
 * 异步队列写入count
 * 无需修改cache的值
 * @param cacheSyncEvent
 */
public void writeStepCount(CacheSyncEvent cacheSyncEvent) {
  log.info("writeStepCount:{}", cacheSyncEvent);
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(cacheSyncEvent.getCacheKey());
  //获取步长是否满足补偿条件
  if (checkStepCondition(cacheSyncEvent, rCacheLong)) {
    //封装
    CacheModelEnum cacheModelEnum = CacheModelEnum.lookup(cacheSyncEvent.getIndex());
    if (retryCountToCache(cacheSyncEvent.getId(), 0, cacheModelEnum, rCacheLong)) {
      //回写DB
      if (rCacheLong.get() > 0) {
        writeValue(rCacheLong.get(), cacheSyncEvent.getId(), cacheModelEnum);
      }
    }
  }
  rCacheLong.expire(AppConfig.COMMON_COUNT_CACHE_DAYS, TimeUnit.DAYS);
}
origin: justlive1/earth-frost

@Override
protected boolean shouldNotify(Event event) {
 JobInfo jobInfo =
   BeanStore.getBean(JobRepository.class).findJobInfoById(event.getData().getJobId());
 if (jobInfo != null && Objects.equals(event.getType(), Event.TYPE.EXECUTE_SUCCESS.name())
   && jobInfo.getChildJobIds() != null && jobInfo.getChildJobIds().length > 0) {
  JobSharding sharding = event.getData().getSharding();
  if (sharding == null) {
   return true;
  }
  int count = (int) BeanStore.getBean(RedissonClient.class).getAtomicLong(String
    .format(JobConfig.EVENT_SHARDING, event.getData().getJobId(),
      event.getData().getLoggerId())).incrementAndGet();
  return count == sharding.getTotal();
 }
 return false;
}
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: xuminwlt/j360-dubbo-app-all

/**
 * MQ异步写去count
 * 需要修改cache的值
 * @param cacheSyncMessage
 */
public void writeMQCount(CacheSyncMessage cacheSyncMessage) {
  //封装
  RAtomicLong rCacheLong = redissonClient.getAtomicLong(cacheSyncMessage.getCacheKey());
  CacheModelEnum cacheModelEnum = CacheModelEnum.lookup(cacheSyncMessage.getIndex());
  //同步redis+db
  if (retryCountToCache(cacheSyncMessage.getId(), 0, cacheModelEnum, rCacheLong)) {
    //修改redis数据
    long value = cacheSyncMessage.isAdd()?rCacheLong.incrementAndGet():rCacheLong.decrementAndGet();
    if (value > 0) {
      writeValue(value, cacheSyncMessage.getId(), cacheModelEnum);
    }
  }
  rCacheLong.expire(AppConfig.COMMON_COUNT_CACHE_DAYS, TimeUnit.DAYS);
}
org.redisson.apiRedissonClientgetAtomicLong

Javadoc

Returns atomicLong instance by name.

Popular methods of RedissonClient

  • 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
  • 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.
  • getBlockingQueue
    Returns unbounded blocking queue instance by name using provided codec for queue objects.
  • getSet,
  • getBlockingQueue,
  • getList,
  • getScoredSortedSet,
  • getExecutorService,
  • getFairLock,
  • getQueue,
  • getReadWriteLock,
  • getListMultimap

Popular in Java

  • Making http requests using okhttp
  • getSystemService (Context)
  • getContentResolver (Context)
  • putExtra (Intent)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Join (org.hibernate.mapping)
  • From CI to AI: The AI layer in your organization
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