Class MemKeyValueStore

    • Field Detail

      • map

        protected final net.jodah.expiringmap.ExpiringMap<String,​byte[]> map
    • Method Detail

      • keyStream

        public Stream<StringkeyStream()
        Description copied from interface: KeyValueStoreProvider
        Returns a Stream of the keys contained in this Key/Value store provider.

        This operation may be slow and should only be used for management or debug purposes.

        Returns:
        the stream of keys
      • keyStream

        public Stream<StringkeyStream​(String prefix)
        Description copied from interface: KeyValueStoreProvider
        Returns a Stream of the keys with the given prefix contained in this Key/Value store provider.

        This operation may be slow and should only be used for management or debug purposes.

        Returns:
        the stream of keys
      • clear

        public void clear()
        Description copied from interface: KeyValueStoreProvider
        Clears the content of this Key/Value store provider.
      • clone

        protected static byte[] clone​(byte[] value)
      • put

        public void put​(String key,
                        byte[] value,
                        long ttl)
        Description copied from interface: KeyValueStore
        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)
      • get

        public byte[] get​(String key)
        Description copied from interface: KeyValueStore
        Retrieves the value associated to the key.
        Parameters:
        key - the key
        Returns:
        the value, or null if there is no value
      • setTTL

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

        public boolean compareAndSet​(String key,
                                     byte[] expected,
                                     byte[] 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.

        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)