Interface KeyValueStore

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long addAndGet​(String key, long delta)
      Atomically adds the delta to the value associated to the key, interpreted as a long represented as a string.
      boolean compareAndSet​(String key, byte[] expected, byte[] value)
      Atomically sets the value associated to the key to the given value if the current value is the expected value.
      boolean compareAndSet​(String key, byte[] expected, byte[] value, long ttl)
      Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.
      boolean compareAndSet​(String key, String expected, String value)
      Atomically sets the value associated to the key to the given value if the current value is the expected value.
      boolean compareAndSet​(String key, String expected, String value, long ttl)
      Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.
      byte[] get​(String key)
      Retrieves the value associated to the key.
      Map<String,​byte[]> get​(Collection<String> keys)
      Retrieves the key/value map associated with the keys.
      Long getLong​(String key)
      Retrieves the value associated to the key.
      Map<String,​Long> getLongs​(Collection<String> keys)
      Retrieves the key/value map associated with the keys.
      String getString​(String key)
      Retrieves the value associated to the key.
      Map<String,​String> getStrings​(Collection<String> keys)
      Retrieves the key/value map associated with the keys.
      void put​(String key, byte[] value)
      Sets the value associated to the key.
      void put​(String key, byte[] value, long ttl)
      Sets the value associated to the key, and a TTL.
      void put​(String key, Long value)
      Sets the value associated to the key.
      void put​(String key, Long value, long ttl)
      Sets the value associated to the key.
      void put​(String key, String value)
      Sets the value associated to the key.
      void put​(String key, String value, long ttl)
      Sets the value associated to the key, and a TTL.
      boolean setTTL​(String key, long ttl)
      Sets the TTL for an existing key.
    • Method Detail

      • put

        void put​(String key,
                 byte[] value)
        Sets the value associated to the key.
        Parameters:
        key - the key
        value - the value, which may be null
      • put

        void put​(String key,
                 String value)
        Sets the value associated to the key.
        Parameters:
        key - the key
        value - the value, which may be null
        Since:
        9.3
      • put

        void put​(String key,
                 Long value)
        Sets the value associated to the key.
        Parameters:
        key - the key
        value - the value, which may be null
        Since:
        10.2
      • put

        void put​(String key,
                 byte[] value,
                 long ttl)
        Sets the value associated to the key, and a TTL.
        Parameters:
        key - the key
        value - the value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
        Since:
        9.3
      • put

        void put​(String key,
                 String value,
                 long ttl)
        Sets the value associated to the key, and a TTL.
        Parameters:
        key - the key
        value - the value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
        Since:
        9.3
      • put

        void put​(String key,
                 Long value,
                 long ttl)
        Sets the value associated to the key.
        Parameters:
        key - the key
        value - the value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
        Since:
        10.2
      • setTTL

        boolean setTTL​(String key,
                       long ttl)
        Sets the TTL for an existing key.
        Parameters:
        key - the key
        ttl - the TTL, in seconds (0 for infinite)
        Returns:
        true if the TTL has been set, or false if the key does not exist
        Since:
        9.3
      • get

        byte[] get​(String key)
        Retrieves the value associated to the key.
        Parameters:
        key - the key
        Returns:
        the value, or null if there is no value
      • get

        Map<String,​byte[]> get​(Collection<String> keys)
        Retrieves the key/value map associated with the keys.
        Parameters:
        keys - the keys
        Returns:
        the key/value map
        Since:
        9.10
      • compareAndSet

        boolean compareAndSet​(String key,
                              byte[] expected,
                              byte[] value)
        Atomically sets the value associated to the key to the given value if the current value is the expected value.

        Note value comparison is done by value and not by reference.

        Parameters:
        key - the key
        expected - the expected value, which may be null
        value - the updated value, which may be null
        Returns:
        true if the value was updated, or false if not (the expected value was not found)
      • compareAndSet

        boolean compareAndSet​(String key,
                              byte[] expected,
                              byte[] value,
                              long ttl)
        Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.

        Note value comparison is done by value and not by reference.

        Parameters:
        key - the key
        expected - the expected value, which may be null
        value - the updated value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
        Returns:
        true if the value was updated, or false if not (the expected value was not found)
        Since:
        9.3
      • compareAndSet

        boolean compareAndSet​(String key,
                              String expected,
                              String value)
        Atomically sets the value associated to the key to the given value if the current value is the expected value.

        Note value comparison is done by value and not by reference.

        Parameters:
        key - the key
        expected - the expected value, which may be null
        value - the updated value, which may be null
        Returns:
        true if the value was updated, or false if not (the expected value was not found)
        Since:
        9.3
      • compareAndSet

        boolean compareAndSet​(String key,
                              String expected,
                              String value,
                              long ttl)
        Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.

        Note value comparison is done by value and not by reference.

        Parameters:
        key - the key
        expected - the expected value, which may be null
        value - the updated value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
        Returns:
        true if the value was updated, or false if not (the expected value was not found)
        Since:
        9.3
      • addAndGet

        long addAndGet​(String key,
                       long delta)
        Atomically adds the delta to the value associated to the key, interpreted as a long represented as a string.

        If the value does not exist (if get(java.lang.String) would return null), it is interpreted as 0.

        Parameters:
        key - the key
        delta - the delta to add
        Returns:
        the new value
        Throws:
        NumberFormatException - if the existing value cannot be interpreted as a long
        Since:
        10.2