Interface IKvStorage

  • All Known Implementing Classes:
    BaseKvDao, CassandraKvStorage, LuceneKvStorage

    public interface IKvStorage
    APIs to access the {key:value} NoSQL storage.
    • Storage can be divided into spaces (namespaces), each space is identified by an unique id
    • key: String
    • value: byte[]
    Since:
    0.10.0
    Author:
    Thanh Nguyen
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void delete​(java.lang.String spaceId, java.lang.String key)
      Delete an existing entry from storage.
      void delete​(java.lang.String spaceId, java.lang.String key, IDeleteCallback callback)
      Delete an existing entry from storage.
      default <T> T get​(IKvEntryMapper<T> mapper, java.lang.String spaceId, java.lang.String key)
      Get/Load an entry by key.
      byte[] get​(java.lang.String spaceId, java.lang.String key)
      Get/Load an entry by key.
      default boolean keyExists​(java.lang.String spaceId, java.lang.String key)
      Check if a key exists.
      default void put​(java.lang.String spaceId, java.lang.String key, byte[] value)
      Put/Store an entry.
      void put​(java.lang.String spaceId, java.lang.String key, byte[] value, IPutCallback<byte[]> callback)
      Put/Store an entry.
      long size​(java.lang.String spaceId)
      Return number of entries.
    • Method Detail

      • delete

        default void delete​(java.lang.String spaceId,
                            java.lang.String key)
                     throws java.io.IOException
        Delete an existing entry from storage.
        Parameters:
        spaceId -
        key -
        Throws:
        java.io.IOException
      • delete

        void delete​(java.lang.String spaceId,
                    java.lang.String key,
                    IDeleteCallback callback)
             throws java.io.IOException
        Delete an existing entry from storage.
        Parameters:
        spaceId -
        key -
        callback -
        Throws:
        java.io.IOException
      • keyExists

        default boolean keyExists​(java.lang.String spaceId,
                                  java.lang.String key)
                           throws java.io.IOException
        Check if a key exists.
        Parameters:
        spaceId -
        key -
        Returns:
        Throws:
        java.io.IOException
      • get

        byte[] get​(java.lang.String spaceId,
                   java.lang.String key)
            throws java.io.IOException
        Get/Load an entry by key.
        Parameters:
        spaceId -
        key -
        Returns:
        Throws:
        java.io.IOException
      • get

        default <T> T get​(IKvEntryMapper<T> mapper,
                          java.lang.String spaceId,
                          java.lang.String key)
                   throws java.io.IOException
        Get/Load an entry by key.
        Parameters:
        mapper -
        spaceId -
        key -
        Returns:
        Throws:
        java.io.IOException
      • put

        default void put​(java.lang.String spaceId,
                         java.lang.String key,
                         byte[] value)
                  throws java.io.IOException
        Put/Store an entry.
        Parameters:
        spaceId -
        key -
        value -
        Throws:
        java.io.IOException
      • put

        void put​(java.lang.String spaceId,
                 java.lang.String key,
                 byte[] value,
                 IPutCallback<byte[]> callback)
          throws java.io.IOException
        Put/Store an entry.
        Parameters:
        spaceId -
        key -
        value -
        callback -
        Throws:
        java.io.IOException
      • size

        long size​(java.lang.String spaceId)
           throws java.io.IOException
        Return number of entries.
        Parameters:
        spaceId -
        Returns:
        number of entries currently in the storage, -1 if counting number entries is not supported
        Throws:
        java.io.IOException