DATAKV-26

This commit is contained in:
Costin Leau
2011-01-27 19:23:33 +02:00
parent d24aaa0820
commit 4ae784c4d8
3 changed files with 1202 additions and 9 deletions

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2011 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.data.keyvalue.redis.connection;
import org.springframework.data.keyvalue.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.keyvalue.redis.connection.StringRedisConnection.StringTuple;
/**
* Default implementation for {@link StringTuple} interface.
*
* @author Costin Leau
*/
public class DefaultStringTuple extends DefaultTuple implements StringTuple {
private final String valueAsString;
/**
* Constructs a new <code>DefaultStringTuple</code> instance.
*
* @param value
* @param score
*/
public DefaultStringTuple(byte[] value, String valueAsString, Double score) {
super(value, score);
this.valueAsString = valueAsString;
}
/**
* Constructs a new <code>DefaultStringTuple</code> instance.
*
* @param tuple
* @param valueAsString
*/
public DefaultStringTuple(Tuple tuple, String valueAsString) {
super(tuple.getValue(), tuple.getScore());
this.valueAsString = valueAsString;
}
@Override
public String getValueAsString() {
return valueAsString;
}
}

View File

@@ -13,17 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.keyvalue.redis.core;
package org.springframework.data.keyvalue.redis.connection;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.data.keyvalue.redis.connection.DataType;
import org.springframework.data.keyvalue.redis.connection.MessageListener;
import org.springframework.data.keyvalue.redis.connection.RedisConnection;
import org.springframework.data.keyvalue.redis.connection.SortParameters;
import org.springframework.data.keyvalue.redis.core.RedisCallback;
import org.springframework.data.keyvalue.redis.core.StringRedisTemplate;
import org.springframework.data.keyvalue.redis.serializer.RedisSerializer;
/**
@@ -37,6 +35,10 @@ import org.springframework.data.keyvalue.redis.serializer.RedisSerializer;
*/
public interface StringRedisConnection extends RedisConnection {
public interface StringTuple extends Tuple {
String getValueAsString();
}
Boolean exists(String key);
Long del(String... keys);
@@ -174,19 +176,19 @@ public interface StringRedisConnection extends RedisConnection {
Set<String> zRange(String key, long start, long end);
Set<Tuple> zRangeWithScore(String key, long start, long end);
Set<StringTuple> zRangeWithScore(String key, long start, long end);
Set<String> zRevRange(String key, long start, long end);
Set<Tuple> zRevRangeWithScore(String key, long start, long end);
Set<StringTuple> zRevRangeWithScore(String key, long start, long end);
Set<String> zRangeByScore(String key, double min, double max);
Set<Tuple> zRangeByScoreWithScore(String key, double min, double max);
Set<StringTuple> zRangeByScoreWithScore(String key, double min, double max);
Set<String> zRangeByScore(String key, double min, double max, long offset, long count);
Set<Tuple> zRangeByScoreWithScore(String key, double min, double max, long offset, long count);
Set<StringTuple> zRangeByScoreWithScore(String key, double min, double max, long offset, long count);
Long zCount(String key, double min, double max);