Class BaseKvDao

  • All Implemented Interfaces:
    IKvStorage, java.lang.AutoCloseable

    public class BaseKvDao
    extends BaseNoSqlDao
    implements IKvStorage
    Base class for {key:value} NoSQL-based DAOs.
    Since:
    0.10.0
    Author:
    Thanh Nguyen
    • Constructor Detail

      • BaseKvDao

        public BaseKvDao()
    • Method Detail

      • delete

        public void delete​(java.lang.String spaceId,
                           java.lang.String key,
                           IDeleteCallback callback)
                    throws java.io.IOException
        Delete an existing entry from storage.
        Specified by:
        delete in interface IKvStorage
        Throws:
        java.io.IOException
      • keyExists

        public boolean keyExists​(java.lang.String spaceId,
                                 java.lang.String key)
                          throws java.io.IOException
        Check if a key exists.
        Specified by:
        keyExists in interface IKvStorage
        Returns:
        Throws:
        java.io.IOException
      • get

        public byte[] get​(java.lang.String spaceId,
                          java.lang.String key)
                   throws java.io.IOException
        Get/Load an entry by key.
        Specified by:
        get in interface IKvStorage
        Returns:
        Throws:
        java.io.IOException
      • get

        public <T> T get​(IKvEntryMapper<T> mapper,
                         java.lang.String spaceId,
                         java.lang.String key)
                  throws java.io.IOException
        Get/Load an entry by key.
        Specified by:
        get in interface IKvStorage
        Returns:
        Throws:
        java.io.IOException
      • put

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

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