DATAREDIS-444 - Return result of delete in DefaultHashOperation.
Delete in DefaultHashOperation returns now the result of the HDEL command. Original pull request: #184. CLA: 169220160326121428 (Ninad Divadkar)
This commit is contained in:
committed by
Mark Paluch
parent
1b3fe81b61
commit
5f9d005cb3
@@ -52,7 +52,7 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
|
||||
|
||||
Long size();
|
||||
|
||||
void delete(Object... keys);
|
||||
Long delete(Object... keys);
|
||||
|
||||
Map<HK, HV> entries();
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@ class DefaultBoundHashOperations<H, HK, HV> extends DefaultBoundKeyOperations<H>
|
||||
* Constructs a new <code>DefaultBoundHashOperations</code> instance.
|
||||
*
|
||||
* @param key
|
||||
* @param template
|
||||
* @param operations
|
||||
*/
|
||||
public DefaultBoundHashOperations(H key, RedisOperations<H, ?> operations) {
|
||||
super(key, operations);
|
||||
this.ops = operations.opsForHash();
|
||||
}
|
||||
|
||||
public void delete(Object... keys) {
|
||||
ops.delete(getKey(), keys);
|
||||
public Long delete(Object... keys) {
|
||||
return ops.delete(getKey(), keys);
|
||||
}
|
||||
|
||||
public HV get(Object key) {
|
||||
|
||||
@@ -201,15 +201,14 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
return deserializeHashValues(rawValues);
|
||||
}
|
||||
|
||||
public void delete(K key, Object... hashKeys) {
|
||||
public Long delete(K key, Object... hashKeys) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[][] rawHashKeys = rawHashKeys(hashKeys);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
return execute(new RedisCallback<Long>() {
|
||||
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.hDel(rawKey, rawHashKeys);
|
||||
return null;
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.hDel(rawKey, rawHashKeys);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Set;
|
||||
*/
|
||||
public interface HashOperations<H, HK, HV> {
|
||||
|
||||
void delete(H key, Object... hashKeys);
|
||||
Long delete(H key, Object... hashKeys);
|
||||
|
||||
Boolean hasKey(H key, Object hashKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user