- remove JedisPoolWrapper
+ improve the contract for some commands + add jedis implementation (using the binary fork)
This commit is contained in:
@@ -96,7 +96,7 @@
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.2-binaryfork-121110</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.datastore.redis.connection;
|
||||
|
||||
import org.springframework.datastore.redis.connection.RedisHashCommands.Entry;
|
||||
|
||||
/**
|
||||
* Default {@link Entry} implementation.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultEntry implements Entry {
|
||||
|
||||
private final String field;
|
||||
private final String value;
|
||||
|
||||
public DefaultEntry(String field, String value) {
|
||||
this.field = field;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getField() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public interface RedisCommands extends RedisTxCommands, RedisStringCommands, Red
|
||||
|
||||
DataType type(byte[] key);
|
||||
|
||||
Collection<byte[]> keys(String pattern);
|
||||
Collection<byte[]> keys(byte[] pattern);
|
||||
|
||||
byte[] randomKey();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.datastore.redis.connection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -26,12 +27,6 @@ import java.util.Set;
|
||||
*/
|
||||
public interface RedisHashCommands {
|
||||
|
||||
public interface Entry {
|
||||
public byte[] getField();
|
||||
|
||||
public byte[] getValue();
|
||||
}
|
||||
|
||||
Boolean hSet(byte[] key, byte[] field, byte[] value);
|
||||
|
||||
Boolean hSetNX(byte[] key, byte[] field, byte[] value);
|
||||
@@ -40,7 +35,7 @@ public interface RedisHashCommands {
|
||||
|
||||
List<byte[]> hMGet(byte[] key, byte[]... fields);
|
||||
|
||||
void hMSet(byte[] key, byte[][] fields, byte[][] values);
|
||||
void hMSet(byte[] key, Map<byte[], byte[]> hashes);
|
||||
|
||||
Integer hIncrBy(byte[] key, byte[] field, int delta);
|
||||
|
||||
@@ -54,5 +49,5 @@ public interface RedisHashCommands {
|
||||
|
||||
List<byte[]> hVals(byte[] key);
|
||||
|
||||
Set<Entry> hGetAll(byte[] key);
|
||||
Map<byte[], byte[]> hGetAll(byte[] key);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ package org.springframework.datastore.redis.connection.jedis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -30,6 +30,8 @@ import org.springframework.datastore.redis.connection.DataType;
|
||||
import org.springframework.datastore.redis.connection.RedisConnection;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import redis.clients.jedis.BinaryJedis;
|
||||
import redis.clients.jedis.BinaryTransaction;
|
||||
import redis.clients.jedis.Client;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
@@ -46,13 +48,13 @@ public class JedisConnection implements RedisConnection {
|
||||
private static final Field CLIENT_FIELD;
|
||||
|
||||
static {
|
||||
CLIENT_FIELD = ReflectionUtils.findField(Jedis.class, "client", Client.class);
|
||||
CLIENT_FIELD = ReflectionUtils.findField(BinaryJedis.class, "client", Client.class);
|
||||
ReflectionUtils.makeAccessible(CLIENT_FIELD);
|
||||
}
|
||||
|
||||
private final Jedis jedis;
|
||||
private final Client client;
|
||||
private final Transaction transaction;
|
||||
private final BinaryTransaction transaction;
|
||||
|
||||
public JedisConnection(Jedis jedis) {
|
||||
this.jedis = jedis;
|
||||
@@ -176,7 +178,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<byte[]> keys(String pattern) {
|
||||
public Collection<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.keys(pattern);
|
||||
@@ -214,10 +216,10 @@ public class JedisConnection implements RedisConnection {
|
||||
public byte[] randomKey() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.randomKey();
|
||||
transaction.randomBinaryKey();
|
||||
return null;
|
||||
}
|
||||
return jedis.randomKey();
|
||||
return jedis.randomBinaryKey();
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
@@ -303,7 +305,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
try {
|
||||
for (String key : keys) {
|
||||
for (byte[] key : keys) {
|
||||
jedis.watch(key);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@@ -379,24 +381,24 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSet(byte[][] keys, byte[][] values) {
|
||||
public void mSet(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.mset(JedisUtils.arrange(keys, values));
|
||||
transaction.mset(JedisUtils.convert(tuples));
|
||||
}
|
||||
jedis.mset(JedisUtils.arrange(keys, values));
|
||||
jedis.mset(JedisUtils.convert(tuples));
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetNX(byte[][] keys, byte[][] values) {
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.msetnx(JedisUtils.arrange(keys, values));
|
||||
transaction.msetnx(JedisUtils.convert(tuples));
|
||||
}
|
||||
jedis.msetnx(JedisUtils.arrange(keys, values));
|
||||
jedis.msetnx(JedisUtils.convert(tuples));
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
@@ -1198,13 +1200,13 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry> hGetAll(byte[] key) {
|
||||
public Map<byte[], byte[]> hGetAll(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.hgetAll(key);
|
||||
return null;
|
||||
}
|
||||
return JedisUtils.convert(jedis.hgetAll(key));
|
||||
return jedis.hgetAll(key);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
@@ -1230,7 +1232,7 @@ public class JedisConnection implements RedisConnection {
|
||||
transaction.hkeys(key);
|
||||
return null;
|
||||
}
|
||||
return new LinkedHashSet<String>(jedis.hkeys(key));
|
||||
return jedis.hkeys(key);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
@@ -1263,13 +1265,12 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hMSet(byte[] key, byte[][] fields, byte[][] values) {
|
||||
Map<String, String> param = JedisUtils.convert(fields, values);
|
||||
public void hMSet(byte[] key, Map<byte[], byte[]> tuple) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.hmset(key, param);
|
||||
transaction.hmset(key, tuple);
|
||||
}
|
||||
jedis.hmset(key, param);
|
||||
jedis.hmset(key, tuple);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
@@ -1282,7 +1283,7 @@ public class JedisConnection implements RedisConnection {
|
||||
transaction.hvals(key);
|
||||
return null;
|
||||
}
|
||||
return jedis.hvals(key);
|
||||
return new ArrayList<byte[]>(jedis.hvals(key));
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
protected Jedis fetchJedisConnector() {
|
||||
try {
|
||||
if (usePool) {
|
||||
return new JedisPoolWrapper(pool.getResource(), pool);
|
||||
return pool.getResource();
|
||||
}
|
||||
return new Jedis(getShardInfo());
|
||||
} catch (TimeoutException ex) {
|
||||
|
||||
@@ -1,587 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.datastore.redis.connection.jedis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.DebugParams;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisMonitor;
|
||||
import redis.clients.jedis.JedisPipeline;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
import redis.clients.jedis.Tuple;
|
||||
import redis.clients.jedis.ZParams;
|
||||
import redis.clients.jedis.Client.LIST_POSITION;
|
||||
|
||||
/**
|
||||
* Wrapper class used for returning to the pool the Jedis connections,
|
||||
* once they are closed.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class JedisPoolWrapper extends Jedis {
|
||||
|
||||
private final Jedis delegate;
|
||||
private final JedisPool pool;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JedisPoolWrapper</code> instance.
|
||||
*
|
||||
* @param host
|
||||
* @param delegate
|
||||
*/
|
||||
public JedisPoolWrapper(Jedis delegate, JedisPool pool) {
|
||||
super((String) null);
|
||||
this.delegate = delegate;
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public Integer append(String key, String value) {
|
||||
return delegate.append(key, value);
|
||||
}
|
||||
|
||||
public String auth(String password) {
|
||||
return delegate.auth(password);
|
||||
}
|
||||
|
||||
public String bgrewriteaof() {
|
||||
return delegate.bgrewriteaof();
|
||||
}
|
||||
|
||||
public String bgsave() {
|
||||
return delegate.bgsave();
|
||||
}
|
||||
|
||||
public List<String> blpop(int timeout, String... keys) {
|
||||
return delegate.blpop(timeout, keys);
|
||||
}
|
||||
|
||||
public List<String> brpop(int timeout, String... keys) {
|
||||
return delegate.brpop(timeout, keys);
|
||||
}
|
||||
|
||||
public List<String> configGet(String pattern) {
|
||||
return delegate.configGet(pattern);
|
||||
}
|
||||
|
||||
public String configSet(String parameter, String value) {
|
||||
return delegate.configSet(parameter, value);
|
||||
}
|
||||
|
||||
public void connect() throws UnknownHostException, IOException {
|
||||
delegate.connect();
|
||||
}
|
||||
|
||||
public Integer dbSize() {
|
||||
return delegate.dbSize();
|
||||
}
|
||||
|
||||
public String debug(DebugParams params) {
|
||||
return delegate.debug(params);
|
||||
}
|
||||
|
||||
public Integer decr(String key) {
|
||||
return delegate.decr(key);
|
||||
}
|
||||
|
||||
public Integer decrBy(String key, int integer) {
|
||||
return delegate.decrBy(key, integer);
|
||||
}
|
||||
|
||||
public Integer del(String... keys) {
|
||||
return delegate.del(keys);
|
||||
}
|
||||
|
||||
public void disconnect() throws IOException {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
public String echo(String string) {
|
||||
return delegate.echo(string);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return delegate.equals(obj);
|
||||
}
|
||||
|
||||
public Integer exists(String key) {
|
||||
return delegate.exists(key);
|
||||
}
|
||||
|
||||
public Integer expire(String key, int seconds) {
|
||||
return delegate.expire(key, seconds);
|
||||
}
|
||||
|
||||
public Integer expireAt(String key, long unixTime) {
|
||||
return delegate.expireAt(key, unixTime);
|
||||
}
|
||||
|
||||
public String flushAll() {
|
||||
return delegate.flushAll();
|
||||
}
|
||||
|
||||
public String flushDB() {
|
||||
return delegate.flushDB();
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return delegate.get(key);
|
||||
}
|
||||
|
||||
public String getSet(String key, String value) {
|
||||
return delegate.getSet(key, value);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
public Integer hdel(String key, String field) {
|
||||
return delegate.hdel(key, field);
|
||||
}
|
||||
|
||||
public Integer hexists(String key, String field) {
|
||||
return delegate.hexists(key, field);
|
||||
}
|
||||
|
||||
public String hget(String key, String field) {
|
||||
return delegate.hget(key, field);
|
||||
}
|
||||
|
||||
public Map<String, String> hgetAll(String key) {
|
||||
return delegate.hgetAll(key);
|
||||
}
|
||||
|
||||
public Integer hincrBy(String key, String field, int value) {
|
||||
return delegate.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public List<String> hkeys(String key) {
|
||||
return delegate.hkeys(key);
|
||||
}
|
||||
|
||||
public Integer hlen(String key) {
|
||||
return delegate.hlen(key);
|
||||
}
|
||||
|
||||
public List<String> hmget(String key, String... fields) {
|
||||
return delegate.hmget(key, fields);
|
||||
}
|
||||
|
||||
public String hmset(String key, Map<String, String> hash) {
|
||||
return delegate.hmset(key, hash);
|
||||
}
|
||||
|
||||
public Integer hset(String key, String field, String value) {
|
||||
return delegate.hset(key, field, value);
|
||||
}
|
||||
|
||||
public Integer hsetnx(String key, String field, String value) {
|
||||
return delegate.hsetnx(key, field, value);
|
||||
}
|
||||
|
||||
public List<String> hvals(String key) {
|
||||
return delegate.hvals(key);
|
||||
}
|
||||
|
||||
public Integer incr(String key) {
|
||||
return delegate.incr(key);
|
||||
}
|
||||
|
||||
public Integer incrBy(String key, int integer) {
|
||||
return delegate.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return delegate.info();
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return delegate.isConnected();
|
||||
}
|
||||
|
||||
public List<String> keys(String pattern) {
|
||||
return delegate.keys(pattern);
|
||||
}
|
||||
|
||||
public Integer lastsave() {
|
||||
return delegate.lastsave();
|
||||
}
|
||||
|
||||
public String lindex(String key, int index) {
|
||||
return delegate.lindex(key, index);
|
||||
}
|
||||
|
||||
public Integer linsert(String key, LIST_POSITION where, String pivot, String value) {
|
||||
return delegate.linsert(key, where, pivot, value);
|
||||
}
|
||||
|
||||
public Integer llen(String key) {
|
||||
return delegate.llen(key);
|
||||
}
|
||||
|
||||
public String lpop(String key) {
|
||||
return delegate.lpop(key);
|
||||
}
|
||||
|
||||
public Integer lpush(String key, String string) {
|
||||
return delegate.lpush(key, string);
|
||||
}
|
||||
|
||||
public Integer lpushx(String key, String string) {
|
||||
return delegate.lpushx(key, string);
|
||||
}
|
||||
|
||||
public List<String> lrange(String key, int start, int end) {
|
||||
return delegate.lrange(key, start, end);
|
||||
}
|
||||
|
||||
public Integer lrem(String key, int count, String value) {
|
||||
return delegate.lrem(key, count, value);
|
||||
}
|
||||
|
||||
public String lset(String key, int index, String value) {
|
||||
return delegate.lset(key, index, value);
|
||||
}
|
||||
|
||||
public String ltrim(String key, int start, int end) {
|
||||
return delegate.ltrim(key, start, end);
|
||||
}
|
||||
|
||||
public List<String> mget(String... keys) {
|
||||
return delegate.mget(keys);
|
||||
}
|
||||
|
||||
public void monitor(JedisMonitor jedisMonitor) {
|
||||
delegate.monitor(jedisMonitor);
|
||||
}
|
||||
|
||||
public Integer move(String key, int dbIndex) {
|
||||
return delegate.move(key, dbIndex);
|
||||
}
|
||||
|
||||
public String mset(String... keysvalues) {
|
||||
return delegate.mset(keysvalues);
|
||||
}
|
||||
|
||||
public Integer msetnx(String... keysvalues) {
|
||||
return delegate.msetnx(keysvalues);
|
||||
}
|
||||
|
||||
public Transaction multi() {
|
||||
return delegate.multi();
|
||||
}
|
||||
|
||||
public List<Object> multi(TransactionBlock jedisTransaction) {
|
||||
return delegate.multi(jedisTransaction);
|
||||
}
|
||||
|
||||
public Integer persist(String key) {
|
||||
return delegate.persist(key);
|
||||
}
|
||||
|
||||
public String ping() {
|
||||
return delegate.ping();
|
||||
}
|
||||
|
||||
public List<Object> pipelined(JedisPipeline jedisPipeline) {
|
||||
return delegate.pipelined(jedisPipeline);
|
||||
}
|
||||
|
||||
public void psubscribe(JedisPubSub jedisPubSub, String... patterns) {
|
||||
delegate.psubscribe(jedisPubSub, patterns);
|
||||
}
|
||||
|
||||
public Integer publish(String channel, String message) {
|
||||
return delegate.publish(channel, message);
|
||||
}
|
||||
|
||||
public void quit() {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
public String randomKey() {
|
||||
return delegate.randomKey();
|
||||
}
|
||||
|
||||
public String rename(String oldkey, String newkey) {
|
||||
return delegate.rename(oldkey, newkey);
|
||||
}
|
||||
|
||||
public Integer renamenx(String oldkey, String newkey) {
|
||||
return delegate.renamenx(oldkey, newkey);
|
||||
}
|
||||
|
||||
public String rpop(String key) {
|
||||
return delegate.rpop(key);
|
||||
}
|
||||
|
||||
public String rpoplpush(String srckey, String dstkey) {
|
||||
return delegate.rpoplpush(srckey, dstkey);
|
||||
}
|
||||
|
||||
public Integer rpush(String key, String string) {
|
||||
return delegate.rpush(key, string);
|
||||
}
|
||||
|
||||
public Integer rpushx(String key, String string) {
|
||||
return delegate.rpushx(key, string);
|
||||
}
|
||||
|
||||
public Integer sadd(String key, String member) {
|
||||
return delegate.sadd(key, member);
|
||||
}
|
||||
|
||||
public String save() {
|
||||
return delegate.save();
|
||||
}
|
||||
|
||||
public Integer scard(String key) {
|
||||
return delegate.scard(key);
|
||||
}
|
||||
|
||||
public Set<String> sdiff(String... keys) {
|
||||
return delegate.sdiff(keys);
|
||||
}
|
||||
|
||||
public Integer sdiffstore(String dstkey, String... keys) {
|
||||
return delegate.sdiffstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public String select(int index) {
|
||||
return delegate.select(index);
|
||||
}
|
||||
|
||||
public String set(String key, String value) {
|
||||
return delegate.set(key, value);
|
||||
}
|
||||
|
||||
public String setex(String key, int seconds, String value) {
|
||||
return delegate.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public Integer setnx(String key, String value) {
|
||||
return delegate.setnx(key, value);
|
||||
}
|
||||
|
||||
public String shutdown() {
|
||||
return delegate.shutdown();
|
||||
}
|
||||
|
||||
public Set<String> sinter(String... keys) {
|
||||
return delegate.sinter(keys);
|
||||
}
|
||||
|
||||
public Integer sinterstore(String dstkey, String... keys) {
|
||||
return delegate.sinterstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public Integer sismember(String key, String member) {
|
||||
return delegate.sismember(key, member);
|
||||
}
|
||||
|
||||
public String slaveof(String host, int port) {
|
||||
return delegate.slaveof(host, port);
|
||||
}
|
||||
|
||||
public String slaveofNoOne() {
|
||||
return delegate.slaveofNoOne();
|
||||
}
|
||||
|
||||
public Set<String> smembers(String key) {
|
||||
return delegate.smembers(key);
|
||||
}
|
||||
|
||||
public Integer smove(String srckey, String dstkey, String member) {
|
||||
return delegate.smove(srckey, dstkey, member);
|
||||
}
|
||||
|
||||
public Integer sort(String key, SortingParams sortingParameters, String dstkey) {
|
||||
return delegate.sort(key, sortingParameters, dstkey);
|
||||
}
|
||||
|
||||
public List<String> sort(String key, SortingParams sortingParameters) {
|
||||
return delegate.sort(key, sortingParameters);
|
||||
}
|
||||
|
||||
public Integer sort(String key, String dstkey) {
|
||||
return delegate.sort(key, dstkey);
|
||||
}
|
||||
|
||||
public List<String> sort(String key) {
|
||||
return delegate.sort(key);
|
||||
}
|
||||
|
||||
public String spop(String key) {
|
||||
return delegate.spop(key);
|
||||
}
|
||||
|
||||
public String srandmember(String key) {
|
||||
return delegate.srandmember(key);
|
||||
}
|
||||
|
||||
public Integer srem(String key, String member) {
|
||||
return delegate.srem(key, member);
|
||||
}
|
||||
|
||||
public Integer strlen(String key) {
|
||||
return delegate.strlen(key);
|
||||
}
|
||||
|
||||
public void subscribe(JedisPubSub jedisPubSub, String... channels) {
|
||||
delegate.subscribe(jedisPubSub, channels);
|
||||
}
|
||||
|
||||
public String substr(String key, int start, int end) {
|
||||
return delegate.substr(key, start, end);
|
||||
}
|
||||
|
||||
public Set<String> sunion(String... keys) {
|
||||
return delegate.sunion(keys);
|
||||
}
|
||||
|
||||
public Integer sunionstore(String dstkey, String... keys) {
|
||||
return delegate.sunionstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public void sync() {
|
||||
delegate.sync();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
public Integer ttl(String key) {
|
||||
return delegate.ttl(key);
|
||||
}
|
||||
|
||||
public String type(String key) {
|
||||
return delegate.type(key);
|
||||
}
|
||||
|
||||
public String unwatch() {
|
||||
return delegate.unwatch();
|
||||
}
|
||||
|
||||
public String watch(String key) {
|
||||
return delegate.watch(key);
|
||||
}
|
||||
|
||||
public Integer zadd(String key, double score, String member) {
|
||||
return delegate.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public Integer zcard(String key) {
|
||||
return delegate.zcard(key);
|
||||
}
|
||||
|
||||
public Integer zcount(String key, double min, double max) {
|
||||
return delegate.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public Double zincrby(String key, double score, String member) {
|
||||
return delegate.zincrby(key, score, member);
|
||||
}
|
||||
|
||||
public Integer zinterstore(String dstkey, String... sets) {
|
||||
return delegate.zinterstore(dstkey, sets);
|
||||
}
|
||||
|
||||
public Integer zinterstore(String dstkey, ZParams params, String... sets) {
|
||||
return delegate.zinterstore(dstkey, params, sets);
|
||||
}
|
||||
|
||||
public Set<String> zrange(String key, int start, int end) {
|
||||
return delegate.zrange(key, start, end);
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(String key, double min, double max, int offset, int count) {
|
||||
return delegate.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(String key, double min, double max) {
|
||||
return delegate.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {
|
||||
return delegate.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
|
||||
return delegate.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeWithScores(String key, int start, int end) {
|
||||
return delegate.zrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Integer zrank(String key, String member) {
|
||||
return delegate.zrank(key, member);
|
||||
}
|
||||
|
||||
public Integer zrem(String key, String member) {
|
||||
return delegate.zrem(key, member);
|
||||
}
|
||||
|
||||
public Integer zremrangeByRank(String key, int start, int end) {
|
||||
return delegate.zremrangeByRank(key, start, end);
|
||||
}
|
||||
|
||||
public Integer zremrangeByScore(String key, double start, double end) {
|
||||
return delegate.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public Set<String> zrevrange(String key, int start, int end) {
|
||||
return delegate.zrevrange(key, start, end);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
|
||||
return delegate.zrevrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Integer zrevrank(String key, String member) {
|
||||
return delegate.zrevrank(key, member);
|
||||
}
|
||||
|
||||
public Double zscore(String key, String member) {
|
||||
return delegate.zscore(key, member);
|
||||
}
|
||||
|
||||
public Integer zunionstore(String dstkey, String... sets) {
|
||||
return delegate.zunionstore(dstkey, sets);
|
||||
}
|
||||
|
||||
public Integer zunionstore(String dstkey, ZParams params, String... sets) {
|
||||
return delegate.zunionstore(dstkey, params, sets);
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
try {
|
||||
pool.returnResource(delegate);
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,7 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.datastore.redis.RedisConnectionFailureException;
|
||||
import org.springframework.datastore.redis.UncategorizedRedisException;
|
||||
import org.springframework.datastore.redis.connection.DefaultEntry;
|
||||
import org.springframework.datastore.redis.connection.DefaultTuple;
|
||||
import org.springframework.datastore.redis.connection.RedisHashCommands.Entry;
|
||||
import org.springframework.datastore.redis.connection.RedisZSetCommands.Tuple;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
@@ -79,19 +77,21 @@ public abstract class JedisUtils {
|
||||
static Set<Tuple> convertJedisTuple(Set<redis.clients.jedis.Tuple> tuples) {
|
||||
Set<Tuple> value = new LinkedHashSet<Tuple>(tuples.size());
|
||||
for (redis.clients.jedis.Tuple tuple : tuples) {
|
||||
value.add(new DefaultTuple(tuple.getElement(), tuple.getScore()));
|
||||
value.add(new DefaultTuple(tuple.getBinaryElement(), tuple.getScore()));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static Set<Entry> convert(Map<String, String> hgetAll) {
|
||||
Set<Entry> entries = new LinkedHashSet<Entry>(hgetAll.size());
|
||||
for (Map.Entry<String, String> entry : hgetAll.entrySet()) {
|
||||
entries.add(new DefaultEntry(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
static byte[][] convert(Map<byte[], byte[]> hgetAll) {
|
||||
byte[][] result = new byte[hgetAll.size() * 2][];
|
||||
|
||||
return entries;
|
||||
int index = 0;
|
||||
for (Map.Entry<byte[], byte[]> entry : hgetAll.entrySet()) {
|
||||
result[index++] = entry.getKey();
|
||||
result[index++] = entry.getValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Map<String, String> convert(String[] fields, String[] values) {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<byte[]> keys(String pattern) {
|
||||
public Collection<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
return JredisUtils.convert(charset, jredis.keys(pattern));
|
||||
} catch (RedisException ex) {
|
||||
|
||||
Reference in New Issue
Block a user