+ add more methods to the RedisOperations

This commit is contained in:
Costin Leau
2010-11-12 18:25:49 +02:00
parent 3a2ff58317
commit 8ed620463f
4 changed files with 129 additions and 4 deletions

View File

@@ -0,0 +1,44 @@
/*
* 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;
/**
* List operations bound to a certain key.
*
* @author Costin Leau
*/
public interface BoundListOperations<K, V> extends RedisKeyedStore<K> {
List<V> range(int start, int end);
void trim(int start, int end);
Integer length();
Integer leftPush(V value);
Integer rightPush(V value);
V leftPop();
V rightPop();
Integer remove(int i, Object value);
V index(int index);
}

View File

@@ -0,0 +1,50 @@
/*
* 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;
/**
* Redis, list specific operations.
*
* @author Costin Leau
*/
public interface ListOperations<K, V> {
List<V> range(K key, int start, int end);
void trim(K key, int start, int end);
Integer length(K key);
Integer leftPush(K key, V value);
Integer rightPush(K key, V value);
void set(K key, int index, V value);
Integer remove(K key, int i, Object value);
V index(K key, int index);
V leftPop(K key);
V rightPop(K key);
V blockingLeftPop(K key);
V blockingRightPop(K key);
}

View File

@@ -0,0 +1,31 @@
/*
* 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;
/**
* Redis store for a certain key. Useful for creating views into Redis 'collection' types.
*
* @author Costin Leau
*/
public interface RedisKeyedStore<K> {
/**
* Returns the key associated with this store.
*
* @return
*/
K getKey();
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.datastore.redis.core;
/**
* Basic set of Redis operations, implemented by {@link RedisTemplate}.
*
@@ -34,10 +35,9 @@ public interface RedisOperations<K, V> {
Object exec();
V incr(K key);
V increment(K key, int delta);
V decr(K key);
V incrBy(K key, int delta);
ListOperations<K, V> listOps();
BoundListOperations<K, V> forList(K key);
}