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

How to use
Converters
in
org.springframework.data.redis.connection.convert

Best Java code snippets using org.springframework.data.redis.connection.convert.Converters (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Assert
  • Jedis
origin: spring-projects/spring-data-redis

@Override
public Properties getConfig(RedisClusterNode node, String pattern) {
  Assert.notNull(pattern, "Pattern must not be null!");
  return connection.getClusterCommandExecutor()
      .executeCommandOnSingleNode(
          (JedisClusterCommandCallback<Properties>) client -> Converters.toProperties(client.configGet(pattern)),
          node)
      .getValue();
}
origin: spring-projects/spring-data-redis

/**
 * Constructs a new <code>DefaultStringRedisConnection</code> instance.
 *
 * @param connection Redis connection
 * @param serializer String serializer
 */
public DefaultStringRedisConnection(RedisConnection connection, RedisSerializer<String> serializer) {
  Assert.notNull(connection, "connection is required");
  Assert.notNull(serializer, "serializer is required");
  this.delegate = connection;
  this.serializer = serializer;
  this.byteGeoResultsToStringGeoResults = Converters.deserializingGeoResultsConverter(serializer);
}
origin: spring-projects/spring-data-redis

@Override
public Properties getConfig(String pattern) {
  Assert.notNull(pattern, "Pattern must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().configGet(pattern),
          Converters.listToPropertiesConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().configGet(pattern),
          Converters.listToPropertiesConverter()));
      return null;
    }
    return Converters.toProperties(connection.getJedis().configGet(pattern));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean set(byte[] key, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().set(key, value),
          Converters.stringToBooleanConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().set(key, value),
          Converters.stringToBooleanConverter()));
      return null;
    }
    return Converters.stringToBoolean(connection.getJedis().set(key, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().psetex(key, milliseconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().psetex(key, milliseconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    return Converters.stringToBoolean(connection.getJedis().psetex(key, milliseconds, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean setEx(byte[] key, long seconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  if (seconds > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("Time must be less than Integer.MAX_VALUE for setEx in Jedis.");
  }
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().setex(key, (int) seconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().setex(key, (int) seconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    return Converters.stringToBoolean(connection.getJedis().setex(key, (int) seconds, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean setEx(byte[] key, long seconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newLettuceResult(getAsyncConnection().setex(key, seconds, value),
          Converters.stringToBooleanConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newLettuceResult(getAsyncConnection().setex(key, seconds, value),
          Converters.stringToBooleanConverter()));
      return null;
    }
    return Converters.stringToBoolean(getConnection().setex(key, seconds, value));
  } catch (Exception ex) {
    throw convertLettuceAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean setEx(byte[] key, long seconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  if (seconds > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("Seconds have cannot exceed Integer.MAX_VALUE!");
  }
  try {
    return Converters.stringToBoolean(connection.getCluster().setex(key, Long.valueOf(seconds).intValue(), value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Long pTtl(byte[] key, TimeUnit timeUnit) {
  Assert.notNull(key, "Key must not be null!");
  return connection.getClusterCommandExecutor()
      .executeCommandOnSingleNode(
          (JedisClusterCommandCallback<Long>) client -> Converters.millisecondsToTimeUnit(client.pttl(key), timeUnit),
          connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
      .getValue();
}
origin: spring-projects/spring-data-redis

@Override
public Long ttl(byte[] key, TimeUnit timeUnit) {
  Assert.notNull(key, "Key must not be null!");
  try {
    return Converters.secondsToTimeUnit(connection.getCluster().ttl(key), timeUnit);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Long ttl(byte[] key, TimeUnit timeUnit) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().ttl(key),
          Converters.secondsToTimeUnit(timeUnit)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().ttl(key),
          Converters.secondsToTimeUnit(timeUnit)));
      return null;
    }
    return Converters.secondsToTimeUnit(connection.getJedis().ttl(key), timeUnit);
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean mSet(Map<byte[], byte[]> tuples) {
  Assert.notNull(tuples, "Tuples must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().mset(JedisConverters.toByteArrays(tuples)),
          Converters.stringToBooleanConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newJedisResult(connection.getRequiredTransaction().mset(JedisConverters.toByteArrays(tuples)),
              Converters.stringToBooleanConverter()));
      return null;
    }
    return Converters.stringToBoolean(connection.getJedis().mset(JedisConverters.toByteArrays(tuples)));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return Converters.stringToBoolean(connection.getClusterCommandExecutor()
      .executeCommandOnSingleNode(
          (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
          connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
      .getValue());
}
origin: spring-projects/spring-data-redis

@Nullable
@Override
public Duration idletime(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().objectIdletime(key),
          Converters::secondsToDuration));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().objectIdletime(key),
          Converters::secondsToDuration));
      return null;
    }
    return Converters.secondsToDuration(connection.getJedis().objectIdletime(key));
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Nullable
@Override
public Duration idletime(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newLettuceResult(getAsyncConnection().objectIdletime(key), Converters::secondsToDuration));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newLettuceResult(getAsyncConnection().objectIdletime(key), Converters::secondsToDuration));
      return null;
    }
    return Converters.secondsToDuration(getConnection().objectIdletime(key));
  } catch (Exception ex) {
    throw convertLettuceAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Long pTtl(byte[] key, TimeUnit timeUnit) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(
          connection.newLettuceResult(getAsyncConnection().pttl(key), Converters.millisecondsToTimeUnit(timeUnit)));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newLettuceResult(getAsyncConnection().pttl(key), Converters.millisecondsToTimeUnit(timeUnit)));
      return null;
    }
    return Converters.millisecondsToTimeUnit(getConnection().pttl(key), timeUnit);
  } catch (Exception ex) {
    throw convertLettuceAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Properties getConfig(String pattern) {
  Assert.hasText(pattern, "Pattern must not be null or empty!");
  try {
    if (isPipelined()) {
      pipeline(connection.newLettuceResult(getAsyncConnection().configGet(pattern),
          Converters.mapToPropertiesConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newLettuceResult(getAsyncConnection().configGet(pattern),
          Converters.mapToPropertiesConverter()));
      return null;
    }
    return Converters.toProperties(getConnection().configGet(pattern));
  } catch (Exception ex) {
    throw convertLettuceAccessException(ex);
  }
}
origin: spring-projects/spring-data-redis

@Override
public Properties getConfig(RedisClusterNode node, String pattern) {
  Assert.hasText(pattern, "Pattern must not be null or empty!");
  return executeCommandOnSingleNode(client -> Converters.toProperties(client.configGet(pattern)), node).getValue();
}
origin: redisson/redisson

private static List<RedisServer> toRedisServersList(List<Map<String, String>> source) {
  List<RedisServer> servers = new ArrayList<RedisServer>(source.size());
  for (Map<String, String> info : source) {
    servers.add(RedisServer.newServerFrom(Converters.toProperties(info)));
  }
  return servers;
}

origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link Converter} to convert from seconds to the given {@link TimeUnit}.
 *
 * @param timeUnit muist not be {@literal null}.
 * @return
 * @since 1.8
 */
public static Converter<Long, Long> secondsToTimeUnit(final TimeUnit timeUnit) {
  return seconds -> secondsToTimeUnit(seconds, timeUnit);
}
org.springframework.data.redis.connection.convertConverters

Javadoc

Common type converters

Most used methods

  • toProperties
  • deserializingGeoResultsConverter
    Converter capable of deserializing GeoResults.
  • listToPropertiesConverter
    Returns a converter to convert array outputs with key-value sequences (such as produced by CONFIG GE
  • mapToPropertiesConverter
    Returns a converter to convert from Map to Properties.
  • millisecondsToTimeUnit
    Creates a new Converter to convert from milliseconds to the given TimeUnit.
  • secondsToDuration
    Convert the given nullable seconds to a Duration or null.
  • secondsToTimeUnit
    Creates a new Converter to convert from seconds to the given TimeUnit.
  • stringToBoolean
  • stringToBooleanConverter
  • toClusterNode
    Converts the result of a single line of CLUSTER NODES into a RedisClusterNode.
  • toSetOfRedisClusterNodes
    Converts lines from the result of CLUSTER NODES into RedisClusterNodes.
  • toTimeMillis
    Returns the timestamp constructed from the given seconds and microseconds.
  • toSetOfRedisClusterNodes,
  • toTimeMillis

Popular in Java

  • Making http requests using okhttp
  • runOnUiThread (Activity)
  • getSharedPreferences (Context)
  • getApplicationContext (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • String (java.lang)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JCheckBox (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • CodeWhisperer 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