Commit cef7a657 authored by wangwei's avatar wangwei

增加传入template参数的方法

parent c26127b5
...@@ -139,6 +139,33 @@ public class RedisBloomHandler<K, V> { ...@@ -139,6 +139,33 @@ public class RedisBloomHandler<K, V> {
}, true); }, true);
} }
public boolean exists(RedisTemplate redisTemplate, K key, V value) {
byte[] rawKey = rawKey(key);
byte[] rawValue = rawValue(value);
return (boolean) redisTemplate.execute(connection -> {
Long l = (Long) connection.execute(EXISTS, rawKey, rawValue);
return Objects.equals(l, 1L);
}, true);
}
public boolean existsString(String key, String value) {
byte[] rawKey = rawString(key);
byte[] rawValue = rawString(value);
return (boolean) redisTemplate.execute(connection -> {
Long l = (Long) connection.execute(EXISTS, rawKey, rawValue);
return Objects.equals(l, 1L);
}, true);
}
public boolean existsString(RedisTemplate redisTemplate, String key, String value) {
byte[] rawKey = rawString(key);
byte[] rawValue = rawString(value);
return (boolean) redisTemplate.execute(connection -> {
Long l = (Long) connection.execute(EXISTS, rawKey, rawValue);
return Objects.equals(l, 1L);
}, true);
}
public Boolean[] existsMulti(K key, V... values) { public Boolean[] existsMulti(K key, V... values) {
byte[][] rawArgs = rawArgs(key, values); byte[][] rawArgs = rawArgs(key, values);
return (Boolean[]) redisTemplate.execute(connection -> { return (Boolean[]) redisTemplate.execute(connection -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment