Package com.github.ddth.dao.nosql
Class BaseKdDao
- java.lang.Object
-
- com.github.ddth.dao.BaseDao
-
- com.github.ddth.dao.nosql.BaseNoSqlDao
-
- com.github.ddth.dao.nosql.BaseKdDao
-
- All Implemented Interfaces:
IKdStorage
,java.lang.AutoCloseable
public class BaseKdDao extends BaseNoSqlDao implements IKdStorage
Base class for {key:document} NoSQL-based DAOs.- Since:
- 0.10.0
- Author:
- Thanh Nguyen
-
-
Constructor Summary
Constructors Constructor Description BaseKdDao()
-
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(IKdEntryMapper<T> mapper, java.lang.String spaceId, java.lang.String key)
Get/Load an entry by key.java.util.Map<java.lang.String,java.lang.Object>
get(java.lang.String spaceId, java.lang.String key)
Get/Load an entry by key.IKdStorage
getKdStorage()
Getter forkdStorage
.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, java.util.Map<java.lang.String,java.lang.Object> document, IPutCallback<java.util.Map<java.lang.String,java.lang.Object>> callback)
Put/Store an entry.BaseKdDao
setKdStorage(IKdStorage kdStorage)
Setter forkdStorage
.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.IKdStorage
delete, put
-
-
-
-
Method Detail
-
getKdStorage
public IKdStorage getKdStorage()
Getter forkdStorage
.- Returns:
-
setKdStorage
public BaseKdDao setKdStorage(IKdStorage kdStorage)
Setter forkdStorage
.- Parameters:
kdStorage
-- 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 interfaceIKdStorage
- 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 interfaceIKdStorage
- Returns:
- Throws:
java.io.IOException
-
get
public java.util.Map<java.lang.String,java.lang.Object> get(java.lang.String spaceId, java.lang.String key) throws java.io.IOException
Get/Load an entry by key.- Specified by:
get
in interfaceIKdStorage
- Returns:
- Throws:
java.io.IOException
-
get
public <T> T get(IKdEntryMapper<T> mapper, java.lang.String spaceId, java.lang.String key) throws java.io.IOException
Get/Load an entry by key.- Specified by:
get
in interfaceIKdStorage
- Returns:
- Throws:
java.io.IOException
-
put
public void put(java.lang.String spaceId, java.lang.String key, java.util.Map<java.lang.String,java.lang.Object> document, IPutCallback<java.util.Map<java.lang.String,java.lang.Object>> callback) throws java.io.IOException
Put/Store an entry.- Specified by:
put
in interfaceIKdStorage
- Throws:
java.io.IOException
-
size
public long size(java.lang.String spaceId) throws java.io.IOException
Return number of entries.- Specified by:
size
in interfaceIKdStorage
- Returns:
- number of entries currently in the storage,
-1
if counting number entries is not supported - Throws:
java.io.IOException
-
-