org.springframework.data.redis.core.RedisTemplate.boundZSetOps()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.springframework.data.redis.core.RedisTemplate.boundZSetOps方法的一些代码示例,展示了RedisTemplate.boundZSetOps的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisTemplate.boundZSetOps方法的具体详情如下:
包路径:org.springframework.data.redis.core.RedisTemplate
类名称:RedisTemplate
方法名:boundZSetOps

RedisTemplate.boundZSetOps介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

final Object payload = message.getPayload();
final BoundZSetOperations<String, Object> ops =
    (BoundZSetOperations<String, Object>) this.redisTemplate.boundZSetOps(zset.getKey());
boolean zsetIncrementHeader = extractZsetIncrementHeader(message);
if (this.extractPayloadElements) {

代码示例来源:origin: dhis2/dhis2-core

@Override
public List<Notification> getNotificationsByJobId( JobType jobType, String jobId )
{
  List<Notification> notifications = new LinkedList<>();
  redisTemplate.boundZSetOps( generateNotificationKey( jobType, jobId ) ).range( 0, -1 ).forEach( x -> {
    try
    {
      notifications.add( objectMapper.readValue( x, Notification.class ) );
    }
    catch ( IOException ex )
    {
      log.warn( String.format( NOTIFIER_ERROR, ex.getMessage() ) );
    }
  } );
  return notifications;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public Map<String, LinkedList<Notification>> getNotificationsByJobType( JobType jobType )
{
  Set<String> notificationKeys = redisTemplate.boundZSetOps( generateNotificationOrderKey( jobType ) ).range( 0,
    -1 );
  LinkedHashMap<String, LinkedList<Notification>> uidNotificationMap = new LinkedHashMap<>();
  notificationKeys
    .forEach( j -> uidNotificationMap.put( j, new LinkedList<>( getNotificationsByJobId( jobType, j ) ) ) );
  return uidNotificationMap;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public List<Notification> getLastNotificationsByJobType( JobType jobType, String lastId )
{
  List<Notification> list = new ArrayList<>();
  Set<String> lastJobUidSet = redisTemplate.boundZSetOps( generateNotificationOrderKey( jobType ) ).range( -1, -1 );
  if ( !lastJobUidSet.iterator().hasNext() )
  {
    return list;
  }
  String lastJobUid = (String) lastJobUidSet.iterator().next();
  for ( Notification notification : getNotificationsByJobId( jobType, lastJobUid ) )
  {
    if ( lastId != null && lastId.equals( notification.getUid() ) )
    {
      break;
    }
    list.add( notification );
  }
  return list;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public Notifier notify( JobConfiguration id, NotificationLevel level, String message, boolean completed )
{
  if ( id != null && !(level != null && level.isOff()) )
  {
    Notification notification = new Notification( level, id.getJobType(), new Date(), message, completed );
    String notificationKey = generateNotificationKey( id.getJobType(), id.getUid() );
    String notificationOrderKey = generateNotificationOrderKey( id.getJobType() );
    Date now = new Date();
    try
    {
      if ( redisTemplate.boundZSetOps( notificationOrderKey ).zCard() >= MAX_POOL_TYPE_SIZE )
      {
        Set<String> deleteKeys = redisTemplate.boundZSetOps( notificationOrderKey ).range( 0, 0 );
        redisTemplate.delete( deleteKeys );
        redisTemplate.boundZSetOps( notificationOrderKey ).removeRange( 0, 0 );
      }
      redisTemplate.boundZSetOps( notificationKey ).add( objectMapper.writeValueAsString( notification ),
        now.getTime() );
      redisTemplate.boundZSetOps( notificationOrderKey ).add( id.getUid(), now.getTime() );
    }
    catch ( JsonProcessingException ex )
    {
      log.warn( String.format( NOTIFIER_ERROR, ex.getMessage() ) );
    }
    log.info( notification );
  }
  return this;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public Object getJobSummary( JobType jobType )
{
  String existingSummaryTypeStr = redisTemplate.boundValueOps( generateSummaryTypeKey( jobType ) ).get();
  if ( existingSummaryTypeStr == null )
  {
    return null;
  }
  
  try
  {
    Class<?> existingSummaryType = Class.forName( existingSummaryTypeStr );
    Set<String> lastJobUidSet = redisTemplate.boundZSetOps( generateSummaryOrderKey( jobType ) ).range( -1,
      -1 );
    if ( !lastJobUidSet.iterator().hasNext() )
    {
      return null;
    }
    String lastJobUid = (String) lastJobUidSet.iterator().next();
    Object serializedSummary = redisTemplate.boundHashOps( generateSummaryKey( jobType ) ).get( lastJobUid );
    return serializedSummary != null ? objectMapper.readValue( (String) serializedSummary, existingSummaryType ) : null;
  }
  catch ( IOException | ClassNotFoundException ex )
  {
    log.warn( String.format( NOTIFIER_ERROR, ex.getMessage() ) );
  }
  return null;
}

代码示例来源:origin: dhis2/dhis2-core

if ( redisTemplate.boundZSetOps( summaryOrderKey ).zCard() >= MAX_POOL_TYPE_SIZE )
  Set<String> summaryKeyToBeDeleted = redisTemplate.boundZSetOps( summaryOrderKey ).range( 0, 0 );
  redisTemplate.boundZSetOps( summaryOrderKey ).removeRange( 0, 0 );
  summaryKeyToBeDeleted.forEach( d -> redisTemplate.boundHashOps( summaryKey ).delete( d ) );
Date now = new Date();
redisTemplate.boundZSetOps( summaryOrderKey ).add( id.getUid(), now.getTime() );

代码示例来源:origin: org.springframework.integration/spring-integration-redis

final Object payload = message.getPayload();
final BoundZSetOperations<String, Object> ops =
    (BoundZSetOperations<String, Object>) this.redisTemplate.boundZSetOps(zset.getKey());
boolean zsetIncrementHeader = extractZsetIncrementHeader(message);
if (this.extractPayloadElements) {

代码示例来源:origin: dhis2/dhis2-core

@Override
public Notifier clear( JobConfiguration id )
{
  if ( id != null )
  {
    redisTemplate.delete( generateNotificationKey( id.getJobType(), id.getUid() ) );
    redisTemplate.boundHashOps( generateSummaryKey( id.getJobType() ) ).delete( id.getUid() );
    redisTemplate.boundZSetOps( generateNotificationOrderKey( id.getJobType() ) ).remove( id.getUid() );
    redisTemplate.boundZSetOps( generateSummaryOrderKey( id.getJobType() ) ).remove( id.getUid() );
  }
  return this;
}

相关文章

微信公众号

最新文章

更多