Package com.github.ddth.dao.nosql
Class BaseKvDao
- java.lang.Object
-
- com.github.ddth.dao.BaseDao
-
- com.github.ddth.dao.nosql.BaseNoSqlDao
-
- com.github.ddth.dao.nosql.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 Summary
Constructors Constructor Description BaseKvDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(java.lang.String spaceId, java.lang.String key, IDeleteCallback callback)
Delete an existing entry from storage.<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.IKvStorage
getKvStorage()
Getter forkvStorage
.boolean
keyExists(java.lang.String spaceId, java.lang.String key)
Check if a key exists.void
put(java.lang.String spaceId, java.lang.String key, byte[] value, IPutCallback<byte[]> callback)
Put/Store an entry.BaseKvDao
setKvStorage(IKvStorage kvStorage)
Setter forkvStorage
.long
size(java.lang.String spaceId)
Return number of entries.-
Methods inherited from class com.github.ddth.dao.nosql.BaseNoSqlDao
calcCacheKey, getCacheName, invalidateCacheEntry, invalidateCacheEntry, setCacheName, wrapCallback
-
Methods inherited from class com.github.ddth.dao.BaseDao
addProfiling, clearProfiling, close, destroy, getCache, getCacheFactory, getFromCache, getFromCache, getProfiling, init, isCacheEnabled, isCacheItemsExpireAfterWrite, putToCache, putToCache, putToCache, removeFromCache, setCacheFactory, setCacheItemsExpireAfterWrite, startProfiling
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.ddth.dao.nosql.IKvStorage
delete, put
-
-
-
-
Method Detail
-
getKvStorage
public IKvStorage getKvStorage()
Getter forkvStorage
.- Returns:
-
setKvStorage
public BaseKvDao setKvStorage(IKvStorage kvStorage)
Setter forkvStorage
.- Parameters:
kvStorage
-- Returns:
-
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 interfaceIKvStorage
- 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 interfaceIKvStorage
- 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 interfaceIKvStorage
- 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 interfaceIKvStorage
- 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 interfaceIKvStorage
- Throws:
java.io.IOException
-
size
public long size(java.lang.String spaceId) throws java.io.IOException
Return number of entries.- Specified by:
size
in interfaceIKvStorage
- Returns:
- number of entries currently in the storage,
-1
if counting number entries is not supported - Throws:
java.io.IOException
-
-