From ef792bac1af7e40a4771c5f18f0f686862f9c968 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Fri, 5 Nov 2010 11:59:23 +0200 Subject: [PATCH] - removed some of the old code --- .../redis/core/AbstractRedisClient.java | 66 --- .../core/AbstractRedisClientFactory.java | 102 ---- .../redis/core/DefaultServerOperations.java | 42 -- .../redis/core/DefaultSetOperations.java | 93 ---- .../datastore/redis/core/ListOperations.java | 29 - .../datastore/redis/core/RedisAccessor.java | 69 --- .../datastore/redis/core/RedisCallback.java | 31 -- .../datastore/redis/core/RedisClient.java | 220 -------- .../redis/core/RedisClientFactory.java | 34 -- .../datastore/redis/core/RedisOperations.java | 42 -- .../datastore/redis/core/RedisTemplate.java | 292 ----------- .../redis/core/ServerOperations.java | 44 -- .../datastore/redis/core/SetOperations.java | 35 -- .../core/jredis/JRedisClientCallback.java | 33 -- .../core/jredis/JRedisClientFactory.java | 111 ---- .../JRedisPersistenceExceptionTranslator.java | 28 - .../redis/core/jredis/JRedisSpringClient.java | 494 ------------------ 17 files changed, 1765 deletions(-) delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClient.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClientFactory.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultServerOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultSetOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ListOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisAccessor.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisCallback.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClient.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClientFactory.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisTemplate.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ServerOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/SetOperations.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientCallback.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientFactory.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisPersistenceExceptionTranslator.java delete mode 100644 spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisSpringClient.java diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClient.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClient.java deleted file mode 100644 index 983f30895..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClient.java +++ /dev/null @@ -1,66 +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.core; - -import java.io.UnsupportedEncodingException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.dao.InvalidDataAccessApiUsageException; - -/** - * Common base class for RedisClient implementations - * @author Mark Pollack - * - */ -public abstract class AbstractRedisClient implements RedisClient { - - protected final Log logger = LogFactory.getLog(this.getClass()); - - public static final String DEFAULT_CHARSET = "UTF-8"; - - private volatile String defaultCharset = DEFAULT_CHARSET; - - /** - * Specify the default charset to use when converting to or from text-based - * Message body content. If not specified, the charset will be "UTF-8". - */ - public void setDefaultCharset(String defaultCharset) { - this.defaultCharset = (defaultCharset != null) ? defaultCharset : DEFAULT_CHARSET; - } - - public String getDefaultCharset() { - return defaultCharset; - } - - protected byte[] stringToByte(String string) throws InvalidDataAccessApiUsageException { - try { - return string.getBytes(this.defaultCharset); - } catch (UnsupportedEncodingException e) { - throw new InvalidDataAccessApiUsageException(defaultCharset - + " encoding not supported.", e); - } - } - - protected String byteToString(byte[] value) throws InvalidDataAccessApiUsageException { - try { - return new String(value, defaultCharset); - } catch (UnsupportedEncodingException e) { - throw new InvalidDataAccessApiUsageException(defaultCharset - + " encoding not supported.", e); - } - } -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClientFactory.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClientFactory.java deleted file mode 100644 index 87de5d108..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/AbstractRedisClientFactory.java +++ /dev/null @@ -1,102 +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.core; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.datastore.redis.support.RedisPersistenceExceptionTranslator; - -/** - * Common base class for RedisClientFactories - * @author Mark Pollack - * - */ -public abstract class AbstractRedisClientFactory implements RedisClientFactory { - - protected final Log logger = LogFactory.getLog(getClass()); - - private String hostName; - - private int port; - - private String password; - - public int getPort() { - return port; - } - - protected void setPort(int port) { - this.port = port; - } - - - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getHostName() { - return hostName; - } - - protected void setHostName(String hostName) { - this.hostName = hostName; - } - - public RedisClient createClient() { - return doGetClient(); - } - - public abstract RedisClient doGetClient(); - - public abstract RedisPersistenceExceptionTranslator getExceptionTranslator(); - - - protected String getDefaultHostName() { - String temp; - try { - InetAddress localMachine = InetAddress.getLocalHost(); - temp = localMachine.getHostName(); - logger.debug("Using hostname [" + temp + "] for hostname."); - } - catch (UnknownHostException e) { - logger.warn("Could not get host name, using 'localhost' as default value", e); - temp = "localhost"; - } - return temp; - } - - /* - public void closeClient() { - if (logger.isDebugEnabled()) { - logger.debug("Closing Redis Client: " + this.client); - } - try { - client.close(); - } - catch (Throwable ex) { - logger.debug("Could not close Redis Client", ex); - } - }*/ - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultServerOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultServerOperations.java deleted file mode 100644 index 83c29932b..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultServerOperations.java +++ /dev/null @@ -1,42 +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.core; - -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class DefaultServerOperations implements ServerOperations { - - protected final Log logger = LogFactory.getLog(getClass()); - - private RedisOperations redisOperations; - - public DefaultServerOperations(RedisOperations redisOperations) { - this.redisOperations = redisOperations; - } - - public Map getServerInfo() { - return redisOperations.execute(new RedisCallback>() { - public Map doInRedis(RedisClient redisClient) - throws Exception { - return redisClient.info(); - } - }); - } - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultSetOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultSetOperations.java deleted file mode 100644 index 35289e357..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/DefaultSetOperations.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.springframework.datastore.redis.core; - -import java.util.Set; - -public class DefaultSetOperations implements SetOperations { - - private RedisTemplate redisTemplate; - public DefaultSetOperations(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - - public boolean add(final String key, final String member) { - return redisTemplate.execute(new RedisCallback() { - public Boolean doInRedis(RedisClient redisClient) throws Exception { - return (redisClient.sadd(key, member) == 0) ? true : false; - } - }); - } - - public Set getAll(final String key) { - return redisTemplate.execute(new RedisCallback>() { - public Set doInRedis(RedisClient redisClient) throws Exception { - return redisClient.smembers(key); - } - }); - } - - public boolean remove(String key, String member) { - // TODO Auto-generated method stub - return false; - } - - public boolean removeRandom(String key) { - // TODO Auto-generated method stub - return false; - } - - public boolean moveBetweenSets(String srckey, String dstkey, String member) { - // TODO Auto-generated method stub - return false; - } - - public int size(String key) { - // TODO Auto-generated method stub - return 0; - } - - public boolean contains(String key, String member) { - // TODO Auto-generated method stub - return false; - } - - public Set getIntersectionOfSets(String... keys) { - // TODO Auto-generated method stub - return null; - } - - public void storeIntersectionOfSets(final String dstkey, final String... keys) { - redisTemplate.execute(new RedisCallback() { - public Void doInRedis(RedisClient redisClient) throws Exception { - redisClient.sinterstore(dstkey, keys); - return null; - } - }); - } - - public Set getUnionOfSets(String... keys) { - // TODO Auto-generated method stub - return null; - } - - public void storeUnionOfSets(String dstkey, String... keys) { - // TODO Auto-generated method stub - - } - - public Set getDifferenceBetweenSets(String... keys) { - // TODO Auto-generated method stub - return null; - } - - public void storeDifferenceBetweenSets(String dstkey, String... keys) { - // TODO Auto-generated method stub - - } - - public String getRandom(String key) { - // TODO Auto-generated method stub - return null; - } - - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ListOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ListOperations.java deleted file mode 100644 index 3e20ac484..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ListOperations.java +++ /dev/null @@ -1,29 +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.core; - -/** - * List operations with 'friendly' names instead of using Redis command names for methods. - * - * May also include List specific helper methods from redis recipies. - * @author Mark Pollack - * - */ -public interface ListOperations { - - - //ListRecipies getListRecipies(); -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisAccessor.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisAccessor.java deleted file mode 100644 index ce94837ba..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisAccessor.java +++ /dev/null @@ -1,69 +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.core; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.util.Assert; - -import com.sun.xml.internal.bind.v2.TODO; - -/** - * Base class for {@link RedisTemplate} and - * other Redis-accessing DAO helpers, defining common properties such as - * RedisClientFactory. - * - * @author Mark Pollack - * - */ -public class RedisAccessor implements InitializingBean { - - /** Logger available to subclasses */ - protected final Log logger = LogFactory.getLog(getClass()); - - private volatile RedisClientFactory redisClientFactory; - - /** - * Set the RedisClientFactory to use for obtaining Redis {@link RedisClient clients}. - */ - public void setRedisClientFactory(RedisClientFactory redisClientFactory) { - this.redisClientFactory = redisClientFactory; - } - - - /** - * Return the RedisClientFactory that this accessor uses for obtaining - * Redis {@link RedisClient Clients}. - */ - public RedisClientFactory getRedisClientFactory() { - return this.redisClientFactory; - } - - /** - * Create a Redis Client - * @return the new Redis Client - * @throws TODO - */ - protected RedisClient createClient() { - return this.redisClientFactory.createClient(); - } - - - public void afterPropertiesSet() { - Assert.notNull(getRedisClientFactory(), "RedisClientfactory is required"); - } -} \ No newline at end of file diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisCallback.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisCallback.java deleted file mode 100644 index a92a0525f..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisCallback.java +++ /dev/null @@ -1,31 +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.core; - -/** - * Basic callback for use in RedisTemplate - * @author Mark Pollack - * - * @param TODO - */ -public interface RedisCallback { - - /** - * Execute any number of operations against the supplied RedisClient - * {@link RedicClient}, possibly returning a result. - */ - T doInRedis(RedisClient redisClient) throws Exception; -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClient.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClient.java deleted file mode 100644 index 961abe4c6..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClient.java +++ /dev/null @@ -1,220 +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.core; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * An interface that is a one to one mapping to Redis commands to method names - * that is portable across various Redis driver libraries. - * - * @author Mark Pollack - * - */ -public interface RedisClient { - - // Connection Management - - void disconnect() throws IOException; - - - // Database control commands - - String save(); - - String bgsave(); - - String bgrewriteaof(); - - Integer lastsave(); - - String shutdown(); - - Map info(); - - //bulk reply callback - monitor - - String slaveof(String host, int port); - - String slaveofNoOne(); - - String select(int index); - - String flushDb(); - - String flushAll(); - - Integer move(String key, int dbIndex); - - String auth(String password); - - Integer dbSize(); - - - // Note: JRedis and the SMA client do not return the response code for set, would probably have to catch exception. - - // Commands operating on string values "StringOperations" or "Operations" - - - /** - * Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB). - *

Time complexity: O(1)

- *

Corresponds to Redis command "SET key value"

- * @see setCommand - * @param key key whose associated value is to be returned - * @param value value to be associated with the specified key - */ - void set(String key, String value); - - void set(String key, byte[] value); - - String get(String key); - - byte[] getAsBytes(String key); - - String getSet(String key, String value); - - List mget(String... keys); - - //TODO mgetAsBytes? Best to have byte[] overloads somewhere else? - - /** - * SETNX works exactly like SET with the only difference that if the key already exists no operation is performed. - * SETNX actually means "SET if Not eXists". - *

Time complexity: O(1)

- *

Corresponds to command "SETNX key value"

- * @see SetnxCommand - * @param key key whose associated value is to be set - * @param value value to be associated with the specified key - * @return 1 if the key was set, 0 if the key was not set - */ - Integer setnx(String key, String value); - - /** - * The command is exactly equivalent to the following group of commands: - *

SET key value - * EXPIRE key time - *

- *

Time complexity: O(1)

- * @see SetexCommand - * @param key key whose associated value is to be set - * @param seconds timeout on the specified key. After the timeout the key will automatically be deleted by the server - * @param value timeout in seconds - * @return Status reply code, OK is success - */ - String setex(String key, int seconds, String value); - - /** - * Set the the respective keys to the respective values. - *

Time complexity: O(1) to set every key

- *

Corresponds to the command "MSET key1 value1 key2 value2 ... keyN valueN"

- * @see MsetCommand - * @param keysvalues key value sequence - * @return OK as MSET can't fail. - */ - //TODO Consider Map here or in template? Map ? - String mset(String... keysvalues); - - Integer msetnx(String... keysvalues); - - Integer incrBy(String key, int increment); - - Integer incr(String key); - - Integer decr(String key); - - Integer decrBy(String key, int decrement); - - //TODO incrementByOne,decrementByOne in template - - /** - * If the key already exists and is a string, this command appends the provided value at the - * end of the string. If the key does not exist it is created and set as an empty string, - * so APPEND will be very similar to SET in this special case. - * @see AppendCommand - * @param key key whose associated value is to be appended - * @param value value to be appended to end of current value associated with the specified key - * @return the total length of the string after the append operation. - */ - Integer append(String key, String value); - - String substr(String key, int start, int end); - - - // Commands operating on all value types "KeySpaceOperations" - - Integer exists(String key); - - Integer del(String... keys); - - String type(String key); - - List keys(String pattern); - - String randomKey(); - - String rename(String oldkey, String newkey); - - Integer renamenx(String oldkey, String newkey); - - Integer expire(String key, int seconds); - - Integer expireAt(String key, long unixTime); - - Integer ttl(String key); - - Integer persist(String key); - - - - - // Probably not possible to abstract at this level across different providers.... - // T sendCommand(String commandName, ReplyTypeMapper mapper, String... commandArgs); - - // Commands operating on Sets - - Integer sadd(String key, String member); - - Set smembers(String key); - - Integer srem(String key, String member); - - String spop(String key); - - Integer smove(String srckey, String dstkey, String member); - - Integer scard(String key); - - Integer sismember(String key, String member); - - Set sinter(String... keys); - - Integer sinterstore(String dstkey, String... keys); - - Set sunion(String... keys); - - Integer sunionstore(String dstkey, String... keys); - - Set sdiff(String... keys); - - Integer sdiffstore(String dstkey, String... keys); - - String srandmember(String key); - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClientFactory.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClientFactory.java deleted file mode 100644 index d92911ab1..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisClientFactory.java +++ /dev/null @@ -1,34 +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.core; - - -import org.springframework.datastore.redis.support.RedisPersistenceExceptionTranslator; - -/** - * An interface based ConnectionFactory for creating {@link RedisClient}s. - * - * @author Mark Pollack - * - */ -public interface RedisClientFactory { - - RedisClient createClient(); - - void setPassword(String password); - - RedisPersistenceExceptionTranslator getExceptionTranslator(); -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisOperations.java deleted file mode 100644 index a243aeba1..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisOperations.java +++ /dev/null @@ -1,42 +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.core; - -import java.util.List; - -import org.springframework.dao.DataAccessException; - -/** - * Interface specifying a set of Redis operations. - * Implemented by {@link RedisTemplate}. - * - * @author Mark Pollack - * - */ -public interface RedisOperations extends KeyValueOperations { - - T execute(RedisCallback action) throws DataAccessException; - - ServerOperations getServerOperations(); - - ListOperations getListOperations(); - - SetOperations getSetOperations(); - - - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisTemplate.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisTemplate.java deleted file mode 100644 index 2009b5d78..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/RedisTemplate.java +++ /dev/null @@ -1,292 +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.core; - -import java.util.List; -import java.util.Map; - -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataRetrievalFailureException; -import org.springframework.datastore.redis.support.RedisUtils; -import org.springframework.datastore.redis.support.converter.DefaultRedisConverter; -import org.springframework.datastore.redis.support.converter.RedisConverter; -import org.springframework.util.Assert; - -/** - * This is the central class in the Redis core package. - * It simplifies the use of Redis and helps to avoid common errors. - * - * @author Mark Pollack - * - */ -public class RedisTemplate extends RedisAccessor implements RedisOperations { - - // TODO perform validation to see if value size > 1GB - // TODO perform validation to see if key contains space, newline or whitespace. - // TODO warning on key size being large > 1024 bytes? - - private RedisConverter redisConverter = new DefaultRedisConverter(); - - private ServerOperations serverOperations; - - public RedisTemplate() { - initDefaults(); - } - public RedisTemplate(RedisClientFactory redisClientFactory) { - this(); - this.setRedisClientFactory(redisClientFactory); - afterPropertiesSet(); - } - - public void setRedisConverter(RedisConverter redisConverter) { - this.redisConverter = redisConverter; - } - - protected void initDefaults() { - serverOperations = new DefaultServerOperations(this); - } - - - - public T execute(RedisCallback action) { - Assert.notNull(action, "Callback object must not be null"); - - RedisClient clientToClose = null; - try { - RedisClient clientToUse = null; //ConnectionFactoryUtils.doGetTransacxtionChannel(getConnectionFactory, this.transactionResourceFactory); - if (clientToUse == null) { - clientToClose = createClient(); - clientToUse = clientToClose; - } - if (logger.isDebugEnabled()) { - logger.debug("Executing callback on Redis Client: " + clientToUse); - } - return action.doInRedis(clientToUse); - } - catch (Exception e) { - throw convertRedisAccessException(e); - } finally { - RedisUtils.closeClient(clientToClose); - } - } - - protected DataAccessException convertRedisAccessException(Exception ex) { - //TODO - return null; - } - - public ServerOperations getServerOperations() { - return serverOperations; - } - - public ListOperations getListOperations() { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - // Key Value Operations - - public String get(final String key) { - return execute(new RedisCallback() { - public String doInRedis(RedisClient redisClient) throws Exception { - return redisClient.get(key); - } - }); - } - - public byte[] getAsBytes(final String key) { - return execute(new RedisCallback() { - public byte[] doInRedis(RedisClient redisClient) throws Exception { - return redisClient.getAsBytes(key); - } - }); - } - - public T getAndConvert(String key, Class requiredType) { - //TODO deserializer exceptions need to be under DAO exception hierarchy. - Object object = redisConverter.deserialize(getAsBytes(key)); - if (requiredType != null && object != null && !requiredType.isAssignableFrom(object.getClass())) { - throw new DataRetrievalFailureException("Can not assign from " + requiredType + " to " + object.getClass()); - } - return (T) object; - } - - public String getAndSet(String key, String value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public byte[] getAndSetBytes(String key, byte[] value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public T getAndSetObject(String key, T value, Class requiredType) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void set(final String key, final String value) { - execute(new RedisCallback() { - public Void doInRedis(RedisClient redisClient) throws Exception { - redisClient.set(key, value); - return null; - } - }); - } - - public void set(String key, String value, long expiryInMillis) { - // TODO Auto-generated method stub - - } - - public void setAsBytes(final String key, final byte[] value) { - execute(new RedisCallback() { - public Void doInRedis(RedisClient redisClient) throws Exception { - redisClient.set(key, value); - return null; - } - }); - - } - - public void setAsBytes(String key, byte[] value, long expiryInMillis) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setIfKeyNonExistent(String key, String value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setIfKeyNonExistent(String key, byte[] value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setMultiple(Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setMultipleAsBytes(Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setMultipleAsBytesIfKeysNonExistent( - Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void setMultipleIfKeysNonExistent(Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public int append(String key, String value) { - throw new RuntimeException("unimplemented"); - } - - public void convertAndSet(String key, Object value) { - setAsBytes(key, this.redisConverter.serialize(value)); - } - - public void convertAndSet(String key, Object value, long expiryInMillis) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void convertAndSetIfKeyNonExistent(String key, Object value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void convertAndSetMultiple(Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public void convertAndSetMultipleIfKeysNonExistent( - Map keysAndValues) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public int decrement(String key) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public int decrementBy(String key, int value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public List getValues(List keys) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public int increment(String key) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public int incrementBy(String key, int value) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - - public String subString(String key, int fromIndex, int toIndex) { - // TODO Auto-generated method stub - throw new RuntimeException("unimplemented"); - } - public List getAndConvertValues(List keys, - Class requiredType) { - // TODO Auto-generated method stub - return null; - } - public String getSubString(String key, int fromIndex, int toIndex) { - // TODO Auto-generated method stub - return null; - } - public boolean containsKey(String key) { - // TODO Auto-generated method stub - return false; - } - public boolean deleteKeys(final String... keys) { - return execute(new RedisCallback() { - public Boolean doInRedis(RedisClient redisClient) throws Exception { - Integer intVal = redisClient.del(keys); - return (intVal == 0) ? false : true; - } - }); - } - - public SetOperations getSetOperations() { - return new DefaultSetOperations(this); - } - - - - - - -} \ No newline at end of file diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ServerOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ServerOperations.java deleted file mode 100644 index b1ba4564e..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/ServerOperations.java +++ /dev/null @@ -1,44 +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.core; - -import java.util.Map; - -/** - * Server operations for Redis - * - * @author Mark Pollack - * - */ -public interface ServerOperations { - - - // Connection handling - - - - - /** - * Calls the Redis 'info' command that returns different information and statistics about the server. - * The reply is parsed into a Map for easy programmatic access. - * Corresponds to the Redis InfoCommand INFO - * @see InfoCommand - * @return - */ - Map getServerInfo(); - - // TODO Commands Monitor, SlaveOf, Config -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/SetOperations.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/SetOperations.java deleted file mode 100644 index d3026e649..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/SetOperations.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.springframework.datastore.redis.core; - -import java.util.Set; - -public interface SetOperations { - - boolean add(String key, String member); - - Set getAll(String key); - - boolean remove(String key, String member); - - boolean removeRandom(String key); - - boolean moveBetweenSets(String srckey, String dstkey, String member); - - int size(String key); - - boolean contains(String key, String member); - - Set getIntersectionOfSets(String... keys); - - void storeIntersectionOfSets(String dstkey, String... keys); - - Set getUnionOfSets(String... keys); - - void storeUnionOfSets(String dstkey, String... keys); - - Set getDifferenceBetweenSets(String... keys); - - void storeDifferenceBetweenSets(String dstkey, String... keys); - - String getRandom(String key); - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientCallback.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientCallback.java deleted file mode 100644 index d1495ec38..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientCallback.java +++ /dev/null @@ -1,33 +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.core.jredis; - -import org.jredis.ri.alphazero.JRedisClient; - -/** - * Basic callback for use in JRedisClient - * @author Mark Pollack - * - * @param TODO - */ -public interface JRedisClientCallback { - - /** - * Execute any number of operations against the supplied RedisClient - * {@link RedicClient}, possibly returning a result. - */ - T doInJRedis(JRedisClient jredisClient) throws Exception; -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientFactory.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientFactory.java deleted file mode 100644 index f043064a7..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisClientFactory.java +++ /dev/null @@ -1,111 +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.core.jredis; - -import java.io.UnsupportedEncodingException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.jredis.ClientRuntimeException; -import org.jredis.connector.ConnectionSpec; -import org.jredis.ri.alphazero.JRedisClient; -import org.jredis.ri.alphazero.connection.DefaultConnectionSpec; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.datastore.redis.core.AbstractRedisClientFactory; -import org.springframework.datastore.redis.core.RedisClient; -import org.springframework.datastore.redis.support.RedisPersistenceExceptionTranslator; - -public class JRedisClientFactory extends AbstractRedisClientFactory { - - public static final String DEFAULT_CHARSET = "UTF-8"; - - private volatile String defaultCharset = DEFAULT_CHARSET; - - - private RedisPersistenceExceptionTranslator exceptionTranslator; - - private ConnectionSpec connectionSpec; - - public JRedisClientFactory() { - setHostName(getDefaultHostName()); - exceptionTranslator = new JRedisPersistenceExceptionTranslator(); - } - - public JRedisClientFactory(ConnectionSpec connectionSpec) { - this.connectionSpec = connectionSpec; - } - - @Override - public RedisClient doGetClient() { - JRedisClient jredis; - if (connectionSpec == null) { - - connectionSpec = DefaultConnectionSpec.newSpec(); - - InetAddress address; - try { - address = InetAddress.getByName(getHostName()); - } catch (UnknownHostException e) { - throw new ClientRuntimeException("unknown host: " - + getHostName(), e); - } - connectionSpec.setAddress(address); - - if (getPort() != 0) { - connectionSpec.setPort(getPort()); - } - - if (getPassword() != null) { - connectionSpec.setCredentials(stringToByte(getPassword())); - } - } - - jredis = new JRedisClient(connectionSpec); - return new JRedisSpringClient(jredis, getExceptionTranslator()); - } - - protected byte[] stringToByte(String string) throws InvalidDataAccessApiUsageException { - try { - return string.getBytes(this.defaultCharset); - } catch (UnsupportedEncodingException e) { - throw new InvalidDataAccessApiUsageException(defaultCharset - + " encoding not supported.", e); - } - } - - /** - * Specify the default charset to use when converting to or from text-based - * Message body content. If not specified, the charset will be "UTF-8". - */ - public void setDefaultCharset(String defaultCharset) { - this.defaultCharset = (defaultCharset != null) ? defaultCharset : DEFAULT_CHARSET; - } - - public String getDefaultCharset() { - return defaultCharset; - } - - @Override - public RedisPersistenceExceptionTranslator getExceptionTranslator() { - return exceptionTranslator; - } - - public void setExceptionTranslator( - RedisPersistenceExceptionTranslator exceptionTranslator) { - this.exceptionTranslator = exceptionTranslator; - } - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisPersistenceExceptionTranslator.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisPersistenceExceptionTranslator.java deleted file mode 100644 index a626614b2..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisPersistenceExceptionTranslator.java +++ /dev/null @@ -1,28 +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.core.jredis; - -import org.springframework.dao.DataAccessException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.datastore.redis.support.RedisPersistenceExceptionTranslator; - -public class JRedisPersistenceExceptionTranslator implements RedisPersistenceExceptionTranslator { - - public DataAccessException translateException(Exception ex) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisSpringClient.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisSpringClient.java deleted file mode 100644 index 02659a6fb..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/core/jredis/JRedisSpringClient.java +++ /dev/null @@ -1,494 +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.core.jredis; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jredis.ri.alphazero.JRedisClient; -import org.jredis.ri.alphazero.support.DefaultCodec; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataRetrievalFailureException; -import org.springframework.datastore.redis.core.AbstractRedisClient; -import org.springframework.datastore.redis.support.RedisPersistenceExceptionTranslator; -import org.springframework.util.Assert; - -/** - * JRedis implementation of RedisClient. Name has 'Spring' in it to avoid naming - * conflict with classes in JRedis itself. - * - * @author Mark Pollack - * - */ -public class JRedisSpringClient extends AbstractRedisClient { - - /** Logger available to subclasses */ - protected final Log logger = LogFactory.getLog(getClass()); - - private JRedisClient _jredisClient; - private RedisPersistenceExceptionTranslator exceptionTranslator; - - public JRedisSpringClient(JRedisClient jredisClient, - RedisPersistenceExceptionTranslator exceptionTransator) { - this._jredisClient = jredisClient; - this.exceptionTranslator = exceptionTransator; - this.setDefaultCharset(DefaultCodec.SUPPORTED_CHARSET_NAME); - } - - - protected Integer convertToInteger(long longTime) { - if (longTime < Integer.MIN_VALUE - || longTime > Integer.MAX_VALUE) { - throw new DataRetrievalFailureException( - longTime - + " cannot be cast to int without changing its value."); - } - return (int) longTime; - } - - public T execute(JRedisClientCallback action) { - Assert.notNull(action, "Callback object must not be null"); - - // TODO jredisClient resource mgmt. - try { - if (logger.isDebugEnabled()) { - logger.debug("Executing callback on JRedisClient : " - + _jredisClient); - } - return action.doInJRedis(_jredisClient); - } catch (Exception e) { - throw convertJRedisAccessException(e); - } - - } - - protected DataAccessException convertJRedisAccessException(Exception ex) { - return exceptionTranslator.translateException(ex); - } - - public void disconnect() { - // TODO look at disconnect exception translation - execute(new JRedisClientCallback() { - public Object doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.quit(); - return null; - } - }); - } - - public String get(final String key) { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - return byteToString(jredisClient.get(key)); - } - }); - } - - public byte[] getAsBytes(final String key) { - return execute(new JRedisClientCallback() { - public byte[] doInJRedis(JRedisClient jredisClient) - throws Exception { - return jredisClient.get(key); - } - }); - } - - public void set(final String key, final String value) { - execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.set(key, value); - return null; - } - }); - } - - public void set(final String key, final byte[] value) { - execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.set(key, value); - return null; - } - }); - } - - public String save() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.save(); - return "OK"; - } - }); - } - - public String bgsave() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.bgsave(); - return "Background saving started"; - } - }); - } - - public String bgrewriteaof() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.bgrewriteaof(); - return "Background append only file rewriting started"; - } - }); - } - - public Integer lastsave() { - return execute(new JRedisClientCallback() { - public Integer doInJRedis(JRedisClient jredisClient) - throws Exception { - long longTime = jredisClient.lastsave(); - // odd that JRedis return long when the Redis command spec says - // int. - return convertToInteger(longTime); - } - }); - } - - public String shutdown() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - throw new UnsupportedOperationException("JRedis does not implement SHUTDOWN command"); - } - }); - } - - public Map info() { - return execute(new JRedisClientCallback>() { - public Map doInJRedis(JRedisClient jredisClient) - throws Exception { - return jredisClient.info(); - } - }); - } - - public String slaveof(final String host, final int port) { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.slaveof(host,port); - return "TODO - EXTRACT CORRECT STRING RESPONSE FROM REDIS FOR COMMAND SLAVEOF"; - } - }); - } - - public String slaveofNoOne() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.slaveofnone(); - return "TODO - EXTRACT CORRECT STRING RESPONSE FROM REDIS FOR COMMAND SLAVEOF NO ONE"; - } - }); - } - - public String select(int index) { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - throw new UnsupportedOperationException("JRedis does not implement SELECT command"); - } - }); - } - - public String flushDb() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.flushdb(); - //TODO why does flushdb() return JRedis interface? - return "OK"; - } - }); - } - - public String flushAll() { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - jredisClient.flushall(); - //TODO why does flushdb() return JRedis interface? - return "OK"; - } - }); - } - - public Integer move(final String key, final int dbIndex) { - return execute(new JRedisClientCallback() { - public Integer doInJRedis(JRedisClient jredisClient) - throws Exception { - return jredisClient.move(key, dbIndex) ? 1 : 0; - } - }); - } - - public String auth(String password) { - return execute(new JRedisClientCallback() { - public String doInJRedis(JRedisClient jredisClient) - throws Exception { - throw new UnsupportedOperationException("JRedis does not implement AUTH command"); - } - }); - } - - public Integer dbSize() { - return execute(new JRedisClientCallback() { - public Integer doInJRedis(JRedisClient jredisClient) - throws Exception { - return convertToInteger(jredisClient.dbsize()); - } - }); - } - - - public String getSet(String key, String value) { - // TODO Auto-generated method stub - return null; - } - - - public List mget(String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Integer setnx(String key, String value) { - // TODO Auto-generated method stub - return null; - } - - - public String setex(String key, int seconds, String value) { - // TODO Auto-generated method stub - return null; - } - - - public String mset(String... keysvalues) { - // TODO Auto-generated method stub - return null; - } - - - public Integer msetnx(String... keysvalues) { - // TODO Auto-generated method stub - return null; - } - - - public Integer incrBy(String key, int increment) { - // TODO Auto-generated method stub - return null; - } - - - public Integer incr(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer decr(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer decrBy(String key, int decrement) { - // TODO Auto-generated method stub - return null; - } - - - public Integer append(String key, String value) { - // TODO Auto-generated method stub - return null; - } - - - public String substr(String key, int start, int end) { - // TODO Auto-generated method stub - return null; - } - - - public Integer exists(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer del(String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public String type(String key) { - // TODO Auto-generated method stub - return null; - } - - - public List keys(String pattern) { - // TODO Auto-generated method stub - return null; - } - - - public String randomKey() { - // TODO Auto-generated method stub - return null; - } - - - public String rename(String oldkey, String newkey) { - // TODO Auto-generated method stub - return null; - } - - - public Integer renamenx(String oldkey, String newkey) { - // TODO Auto-generated method stub - return null; - } - - - public Integer expire(String key, int seconds) { - // TODO Auto-generated method stub - return null; - } - - - public Integer expireAt(String key, long unixTime) { - // TODO Auto-generated method stub - return null; - } - - - public Integer ttl(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer persist(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer sadd(String key, String member) { - // TODO Auto-generated method stub - return null; - } - - - public Set smembers(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer srem(String key, String member) { - // TODO Auto-generated method stub - return null; - } - - - public String spop(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer smove(String srckey, String dstkey, String member) { - // TODO Auto-generated method stub - return null; - } - - - public Integer scard(String key) { - // TODO Auto-generated method stub - return null; - } - - - public Integer sismember(String key, String member) { - // TODO Auto-generated method stub - return null; - } - - - public Set sinter(String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Integer sinterstore(String dstkey, String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Set sunion(String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Integer sunionstore(String dstkey, String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Set sdiff(String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public Integer sdiffstore(String dstkey, String... keys) { - // TODO Auto-generated method stub - return null; - } - - - public String srandmember(String key) { - // TODO Auto-generated method stub - return null; - } - -}