Module lettuce.core

Interface RedisStringCommands<K,​V>

Type Parameters:
K - Key type.
V - Value type.
All Known Subinterfaces:
RedisAdvancedClusterCommands<K,​V>, RedisClusterCommands<K,​V>, RedisClusterPubSubCommands<K,​V>, RedisCommands<K,​V>, RedisPubSubCommands<K,​V>

public interface RedisStringCommands<K,​V>
Synchronous executed commands for Strings.
Since:
4.0
Author:
Mark Paluch
Generated class:
by io.lettuce.apigenerator.CreateSyncApi
  • Method Summary

    Modifier and Type Method Description
    Long append​(K key, V value)
    Append a value to a key.
    Long bitcount​(K key)
    Count set bits in a string.
    Long bitcount​(K key, long start, long end)
    Count set bits in a string.
    List<Long> bitfield​(K key, BitFieldArgs bitFieldArgs)
    Execute BITFIELD with its subcommands.
    Long bitopAnd​(K destination, K... keys)
    Perform bitwise AND between strings.
    Long bitopNot​(K destination, K source)
    Perform bitwise NOT between strings.
    Long bitopOr​(K destination, K... keys)
    Perform bitwise OR between strings.
    Long bitopXor​(K destination, K... keys)
    Perform bitwise XOR between strings.
    Long bitpos​(K key, boolean state)
    Find first bit set or clear in a string.
    Long bitpos​(K key, boolean state, long start)
    Find first bit set or clear in a string.
    Long bitpos​(K key, boolean state, long start, long end)
    Find first bit set or clear in a string.
    Long decr​(K key)
    Decrement the integer value of a key by one.
    Long decrby​(K key, long amount)
    Decrement the integer value of a key by the given number.
    V get​(K key)
    Get the value of a key.
    Long getbit​(K key, long offset)
    Returns the bit value at offset in the string value stored at key.
    V getdel​(K key)
    Get the value of key and delete the key.
    V getex​(K key, GetExArgs args)
    Get the value of key and optionally set its expiration.
    V getrange​(K key, long start, long end)
    Get a substring of the string stored at a key.
    V getset​(K key, V value)
    Set the string value of a key and return its old value.
    Long incr​(K key)
    Increment the integer value of a key by one.
    Long incrby​(K key, long amount)
    Increment the integer value of a key by the given amount.
    Double incrbyfloat​(K key, double amount)
    Increment the float value of a key by the given amount.
    Long mget​(KeyValueStreamingChannel<K,​V> channel, K... keys)
    Stream over the values of all the given keys.
    List<KeyValue<K,​V>> mget​(K... keys)
    Get the values of all the given keys.
    String mset​(Map<K,​V> map)
    Set multiple keys to multiple values.
    Boolean msetnx​(Map<K,​V> map)
    Set multiple keys to multiple values, only if none of the keys exist.
    String psetex​(K key, long milliseconds, V value)
    Set the value and expiration in milliseconds of a key.
    String set​(K key, V value)
    Set the string value of a key.
    String set​(K key, V value, SetArgs setArgs)
    Set the string value of a key.
    Long setbit​(K key, long offset, int value)
    Sets or clears the bit at offset in the string value stored at key.
    String setex​(K key, long seconds, V value)
    Set the value and expiration of a key.
    V setGet​(K key, V value)
    Set the string value of a key and return its old value.
    V setGet​(K key, V value, SetArgs setArgs)
    Set the string value of a key and return its old value.
    Boolean setnx​(K key, V value)
    Set the value of a key, only if the key does not exist.
    Long setrange​(K key, long offset, V value)
    Overwrite part of a string at key starting at the specified offset.
    StringMatchResult stralgoLcs​(StrAlgoArgs strAlgoArgs)
    The STRALGO command implements complex algorithms that operate on strings.
    Long strlen​(K key)
    Get the length of the value stored in a key.
  • Method Details

    • append

      Long append​(K key, V value)
      Append a value to a key.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      Long integer-reply the length of the string after the append operation.
    • bitcount

      Long bitcount​(K key)
      Count set bits in a string.
      Parameters:
      key - the key.
      Returns:
      Long integer-reply The number of bits set to 1.
    • bitcount

      Long bitcount​(K key, long start, long end)
      Count set bits in a string.
      Parameters:
      key - the key.
      start - the start.
      end - the end.
      Returns:
      Long integer-reply The number of bits set to 1.
    • bitfield

      List<Long> bitfield​(K key, BitFieldArgs bitFieldArgs)
      Execute BITFIELD with its subcommands.
      Parameters:
      key - the key.
      bitFieldArgs - the args containing subcommands, must not be null.
      Returns:
      Long bulk-reply the results from the bitfield commands.
    • bitpos

      Long bitpos​(K key, boolean state)
      Find first bit set or clear in a string.
      Parameters:
      key - the key.
      state - the state.
      Returns:
      Long integer-reply The command returns the position of the first bit set to 1 or 0 according to the request. If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns the first bit not part of the string on the right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will return 24, since up to bit 23 all the bits are 1. Basically the function consider the right of the string as padded with zeros if you look for clear bits and specify no range or the start argument only.
    • bitpos

      Long bitpos​(K key, boolean state, long start)
      Find first bit set or clear in a string.
      Parameters:
      key - the key.
      state - the bit type: long.
      start - the start type: long.
      Returns:
      Long integer-reply The command returns the position of the first bit set to 1 or 0 according to the request. If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns the first bit not part of the string on the right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will return 24, since up to bit 23 all the bits are 1. Basically the function consider the right of the string as padded with zeros if you look for clear bits and specify no range or the start argument only.
      Since:
      5.0.1
    • bitpos

      Long bitpos​(K key, boolean state, long start, long end)
      Find first bit set or clear in a string.
      Parameters:
      key - the key.
      state - the bit type: long.
      start - the start type: long.
      end - the end type: long.
      Returns:
      Long integer-reply The command returns the position of the first bit set to 1 or 0 according to the request. If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns the first bit not part of the string on the right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will return 24, since up to bit 23 all the bits are 1. Basically the function consider the right of the string as padded with zeros if you look for clear bits and specify no range or the start argument only. However this behavior changes if you are looking for clear bits and specify a range with both start and end. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear range and there are no 0 bits in that range.
    • bitopAnd

      Long bitopAnd​(K destination, K... keys)
      Perform bitwise AND between strings.
      Parameters:
      destination - result key of the operation.
      keys - operation input key names.
      Returns:
      Long integer-reply The size of the string stored in the destination key, that is equal to the size of the longest input string.
    • bitopNot

      Long bitopNot​(K destination, K source)
      Perform bitwise NOT between strings.
      Parameters:
      destination - result key of the operation.
      source - operation input key names.
      Returns:
      Long integer-reply The size of the string stored in the destination key, that is equal to the size of the longest input string.
    • bitopOr

      Long bitopOr​(K destination, K... keys)
      Perform bitwise OR between strings.
      Parameters:
      destination - result key of the operation.
      keys - operation input key names.
      Returns:
      Long integer-reply The size of the string stored in the destination key, that is equal to the size of the longest input string.
    • bitopXor

      Long bitopXor​(K destination, K... keys)
      Perform bitwise XOR between strings.
      Parameters:
      destination - result key of the operation.
      keys - operation input key names.
      Returns:
      Long integer-reply The size of the string stored in the destination key, that is equal to the size of the longest input string.
    • decr

      Long decr​(K key)
      Decrement the integer value of a key by one.
      Parameters:
      key - the key.
      Returns:
      Long integer-reply the value of key after the decrement.
    • decrby

      Long decrby​(K key, long amount)
      Decrement the integer value of a key by the given number.
      Parameters:
      key - the key.
      amount - the decrement type: long.
      Returns:
      Long integer-reply the value of key after the decrement.
    • get

      V get​(K key)
      Get the value of a key.
      Parameters:
      key - the key.
      Returns:
      V bulk-string-reply the value of key, or null when key does not exist.
    • getbit

      Long getbit​(K key, long offset)
      Returns the bit value at offset in the string value stored at key.
      Parameters:
      key - the key.
      offset - the offset type: long.
      Returns:
      Long integer-reply the bit value stored at offset.
    • getdel

      V getdel​(K key)
      Get the value of key and delete the key.
      Parameters:
      key - the key.
      Returns:
      V bulk-string-reply the value of key, or null when key does not exist.
      Since:
      6.1
    • getex

      V getex​(K key, GetExArgs args)
      Get the value of key and optionally set its expiration.
      Parameters:
      key - the key.
      args - the arguments for GETEX.
      Returns:
      V bulk-string-reply the value of key, or null when key does not exist.
      Since:
      6.1
    • getrange

      V getrange​(K key, long start, long end)
      Get a substring of the string stored at a key.
      Parameters:
      key - the key.
      start - the start type: long.
      end - the end type: long.
      Returns:
      V bulk-string-reply.
    • getset

      V getset​(K key, V value)
      Set the string value of a key and return its old value.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      V bulk-string-reply the old value stored at key, or null when key did not exist.
    • incr

      Long incr​(K key)
      Increment the integer value of a key by one.
      Parameters:
      key - the key.
      Returns:
      Long integer-reply the value of key after the increment.
    • incrby

      Long incrby​(K key, long amount)
      Increment the integer value of a key by the given amount.
      Parameters:
      key - the key.
      amount - the increment type: long.
      Returns:
      Long integer-reply the value of key after the increment.
    • incrbyfloat

      Double incrbyfloat​(K key, double amount)
      Increment the float value of a key by the given amount.
      Parameters:
      key - the key.
      amount - the increment type: double.
      Returns:
      Double bulk-string-reply the value of key after the increment.
    • mget

      List<KeyValue<K,​V>> mget​(K... keys)
      Get the values of all the given keys.
      Parameters:
      keys - the key.
      Returns:
      List<V> array-reply list of values at the specified keys.
    • mget

      Long mget​(KeyValueStreamingChannel<K,​V> channel, K... keys)
      Stream over the values of all the given keys.
      Parameters:
      channel - the channel.
      keys - the keys.
      Returns:
      Long array-reply list of values at the specified keys.
    • mset

      String mset​(Map<K,​V> map)
      Set multiple keys to multiple values.
      Parameters:
      map - the null.
      Returns:
      String simple-string-reply always OK since MSET can't fail.
    • msetnx

      Boolean msetnx​(Map<K,​V> map)
      Set multiple keys to multiple values, only if none of the keys exist.
      Parameters:
      map - the null.
      Returns:
      Boolean integer-reply specifically: 1 if the all the keys were set. 0 if no key was set (at least one key already existed).
    • set

      String set​(K key, V value)
      Set the string value of a key.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      String simple-string-reply OK if SET was executed correctly.
    • set

      String set​(K key, V value, SetArgs setArgs)
      Set the string value of a key.
      Parameters:
      key - the key.
      value - the value.
      setArgs - the setArgs.
      Returns:
      String simple-string-reply OK if SET was executed correctly.
    • setGet

      V setGet​(K key, V value)
      Set the string value of a key and return its old value.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      V bulk-string-reply the old value stored at key, or null when key did not exist.
      Since:
      6.1
    • setGet

      V setGet​(K key, V value, SetArgs setArgs)
      Set the string value of a key and return its old value.
      Parameters:
      key - the key.
      value - the value.
      setArgs - the command arguments.
      Returns:
      V bulk-string-reply the old value stored at key, or null when key did not exist.
      Since:
      6.1
    • setbit

      Long setbit​(K key, long offset, int value)
      Sets or clears the bit at offset in the string value stored at key.
      Parameters:
      key - the key.
      offset - the offset type: long.
      value - the value type: string.
      Returns:
      Long integer-reply the original bit value stored at offset.
    • setex

      String setex​(K key, long seconds, V value)
      Set the value and expiration of a key.
      Parameters:
      key - the key.
      seconds - the seconds type: long.
      value - the value.
      Returns:
      String simple-string-reply.
    • psetex

      String psetex​(K key, long milliseconds, V value)
      Set the value and expiration in milliseconds of a key.
      Parameters:
      key - the key.
      milliseconds - the milliseconds type: long.
      value - the value.
      Returns:
      String simple-string-reply.
    • setnx

      Boolean setnx​(K key, V value)
      Set the value of a key, only if the key does not exist.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      Boolean integer-reply specifically: 1 if the key was set 0 if the key was not set.
    • setrange

      Long setrange​(K key, long offset, V value)
      Overwrite part of a string at key starting at the specified offset.
      Parameters:
      key - the key.
      offset - the offset type: long.
      value - the value.
      Returns:
      Long integer-reply the length of the string after it was modified by the command.
    • stralgoLcs

      StringMatchResult stralgoLcs​(StrAlgoArgs strAlgoArgs)
      The STRALGO command implements complex algorithms that operate on strings. This method uses the LCS algorithm (longest common substring).
      • Without modifiers the string representing the longest common substring is returned.
      • When LEN is given the command returns the length of the longest common substring.
      • When IDX is given the command returns an array with the LCS length and all the ranges in both the strings, start and end offset for each string, where there are matches. When WITHMATCHLEN is given each array representing a match will also have the length of the match.
      Parameters:
      strAlgoArgs - command arguments.
      Returns:
      StringMatchResult.
      Since:
      6.0
    • strlen

      Long strlen​(K key)
      Get the length of the value stored in a key.
      Parameters:
      key - the key.
      Returns:
      Long integer-reply the length of the string at key, or 0 when key does not exist.