diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/support/RedisUtils.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/support/RedisUtils.java deleted file mode 100644 index 433d45f25..000000000 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/support/RedisUtils.java +++ /dev/null @@ -1,54 +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.support; - -import java.io.IOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.datastore.redis.core.RedisClient; - -/** - * Generic utility methods for working with Redis. Mainly for internal use - * within the framework. - * @author Mark Pollack - * - */ -public class RedisUtils { - - - private static final Log logger = LogFactory.getLog(RedisUtils.class); - - - /** - * Close the given Redis Client and ignore any thrown exception. - * This is useful for typical finally blocks in manual Redis code. - * @param channel the RabbitMQ Channel to close (may be null) - */ - public static void closeClient(RedisClient redisClient) { - if (redisClient != null) { - try { - redisClient.disconnect(); - } - catch (IOException ex) { - logger.debug("Could not close Redis Channel", ex); - } - catch (Throwable ex) { - logger.debug("Unexpected exception on closing Redis Client", ex); - } - } - } -} diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/AbstractRedisCollection.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/AbstractRedisCollection.java index 6077d7f9b..5c5f12cc4 100644 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/AbstractRedisCollection.java +++ b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/AbstractRedisCollection.java @@ -26,7 +26,7 @@ public abstract class AbstractRedisCollection implements RedisCollection { } public void clear() { - redisTemplate.deleteKeys(redisKey); + // redisTemplate.deleteKeys(redisKey); } public boolean isEmpty() { diff --git a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/RedisSet.java b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/RedisSet.java index 0cf25d240..d84aa079a 100644 --- a/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/RedisSet.java +++ b/spring-datastore-redis/src/main/java/org/springframework/datastore/redis/util/RedisSet.java @@ -12,86 +12,97 @@ import org.springframework.datastore.redis.core.RedisTemplate; */ public class RedisSet extends AbstractRedisCollection implements Set { - public RedisSet(RedisTemplate redisTemplate, String redisKey) { - super(redisTemplate, redisKey); - } - - public int size() { - return redisTemplate.getSetOperations().size(redisKey); - } + public RedisSet(RedisTemplate redisTemplate, String redisKey) { + super(redisTemplate, redisKey); + } - public boolean contains(Object o) { - //TODO investigate cast - return redisTemplate.getSetOperations().contains(redisKey, (String)o); - } + public int size() { + // return redisTemplate.getSetOperations().size(redisKey); + throw new UnsupportedOperationException(); + } - public Iterator iterator() { - return redisTemplate.getSetOperations().getAll(redisKey).iterator(); - } + public boolean contains(Object o) { + //TODO investigate cast + // return redisTemplate.getSetOperations().contains(redisKey, (String)o); + throw new UnsupportedOperationException(); + } - public boolean add(Object o) { - //TODO investigate cast - return redisTemplate.getSetOperations().add(redisKey, (String)o); - } + public Iterator iterator() { + // return redisTemplate.getSetOperations().getAll(redisKey).iterator(); + throw new UnsupportedOperationException(); + } - public boolean remove(Object o) { - //TODO investigate cast - return redisTemplate.getSetOperations().remove(redisKey, (String)o); - } + public boolean add(Object o) { + //TODO investigate cast + // return redisTemplate.getSetOperations().add(redisKey, (String)o); + throw new UnsupportedOperationException(); + } + + public boolean remove(Object o) { + //TODO investigate cast + // return redisTemplate.getSetOperations().remove(redisKey, (String)o); + throw new UnsupportedOperationException(); + } - public Set members() { - return redisTemplate.getSetOperations().getAll(redisKey); - } + public Set members() { + // return redisTemplate.getSetOperations().getAll(redisKey); + throw new UnsupportedOperationException(); + } - /* - public List members(final int offset, final int max) { - return redisTemplate.sort(redisKey, redisTemplate.sortParams().limit(offset, max)); + /* + public List members(final int offset, final int max) { + return redisTemplate.sort(redisKey, redisTemplate.sortParams().limit(offset, max)); - }*/ + }*/ - public String getRandom() { - return redisTemplate.getSetOperations().getRandom(redisKey); - } + public String getRandom() { + // return redisTemplate.getSetOperations().getRandom(redisKey); + throw new UnsupportedOperationException(); + } + + public boolean removeRandom() { + // return redisTemplate.getSetOperations().removeRandom(redisKey); + throw new UnsupportedOperationException(); + } - public boolean removeRandom() { - return redisTemplate.getSetOperations().removeRandom(redisKey); - } - /* public intersection(RedisSet... redisSets) { //storeIntersectionOfSets.. return null; } */ - + public RedisSet intersection(String newKey, RedisSet... redisSets) { - String[] keys = new String[redisSets.length]; + throw new UnsupportedOperationException(); + /* + String[] keys = new String[redisSets.length]; int i = 0; for (RedisSet redisSet : redisSets) { keys[i] = redisSet.getRedisKey(); i++; } redisTemplate.getSetOperations().storeIntersectionOfSets(newKey, keys); - - RedisSet resultSet = new RedisSet(redisTemplate, newKey); + + RedisSet resultSet = new RedisSet(redisTemplate, newKey); Set results = redisTemplate.getSetOperations().getAll(newKey); resultSet.addAll(results); return resultSet; + */ } - + void union(RedisSet... redisSets) { //storeUnionOfSets } - + void difference(RedisSet... redisSets) { - - } - + + } + //consider methods in google collections such as // cartesianProduct, filter, powerSet, symmetricDifference, newRedisSet - //TODO move to another set - - // + //TODO move to another set + + // }