Class AbstractKeyValueStoreProvider

    • Constructor Detail

      • AbstractKeyValueStoreProvider

        public AbstractKeyValueStoreProvider()
    • Method Detail

      • stringToBytes

        protected static byte[] stringToBytes​(String string)
        Converts a String to UTF-8 bytes.
      • longToBytes

        protected static byte[] longToBytes​(Long value)
        Converts a long to UTF-8 bytes.
      • put

        public void put​(String key,
                        byte[] value)
        Description copied from interface: KeyValueStore
        Sets the value associated to the key.
        Specified by:
        put in interface KeyValueStore
        Parameters:
        key - the key
        value - the value, which may be null
      • put

        public void put​(String key,
                        String value)
        Description copied from interface: KeyValueStore
        Sets the value associated to the key.
        Specified by:
        put in interface KeyValueStore
        Parameters:
        key - the key
        value - the value, which may be null
      • put

        public void put​(String key,
                        String value,
                        long ttl)
        Description copied from interface: KeyValueStore
        Sets the value associated to the key, and a TTL.
        Specified by:
        put in interface KeyValueStore
        Parameters:
        key - the key
        value - the value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
      • put

        public void put​(String key,
                        Long value)
        Description copied from interface: KeyValueStore
        Sets the value associated to the key.
        Specified by:
        put in interface KeyValueStore
        Parameters:
        key - the key
        value - the value, which may be null
      • put

        public void put​(String key,
                        Long value,
                        long ttl)
        Description copied from interface: KeyValueStore
        Sets the value associated to the key.
        Specified by:
        put in interface KeyValueStore
        Parameters:
        key - the key
        value - the value, which may be null
        ttl - the TTL, in seconds (0 for infinite)
      • getString

        public String getString​(String key)
        Description copied from interface: KeyValueStore
        Retrieves the value associated to the key.
        Specified by:
        getString in interface KeyValueStore
        Parameters:
        key - the key
        Returns:
        the value, or null if there is no value
      • get

        public Map<String,​byte[]> get​(Collection<String> keys)
        Description copied from interface: KeyValueStore
        Retrieves the key/value map associated with the keys.
        Specified by:
        get in interface KeyValueStore
        Parameters:
        keys - the keys
        Returns:
        the key/value map
      • compareAndSet

        public boolean compareAndSet​(String key,
                                     byte[] expected,
                                     byte[] value)
        Description copied from interface: KeyValueStore
        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.

        Specified by:
        compareAndSet in interface KeyValueStore
        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

        public boolean compareAndSet​(String key,
                                     String expected,
                                     String value)
        Description copied from interface: KeyValueStore
        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.

        Specified by:
        compareAndSet in interface KeyValueStore
        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

        public boolean compareAndSet​(String key,
                                     String expected,
                                     String value,
                                     long ttl)
        Description copied from interface: KeyValueStore
        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.

        Specified by:
        compareAndSet in interface KeyValueStore
        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)