+ rename RedisKeyStore to KeyBound
+ add default implementations for BoundListOperations & co + wire RedisOperations into RedisTemplate
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface BoundListOperations<K, V> extends RedisKeyedStore<K> {
|
||||
public interface BoundListOperations<K, V> extends KeyBound<K> {
|
||||
|
||||
List<V> range(int start, int end);
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation for {@link BoundListOperations}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultBoundListOperations<K, V> extends DefaultKeyBound<K> implements BoundListOperations<K, V> {
|
||||
|
||||
private final ListOperations<K, V> ops;
|
||||
|
||||
public DefaultBoundListOperations(K key, RedisTemplate<K, V> template) {
|
||||
super(key);
|
||||
this.ops = template.listOps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V index(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V leftPop() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer leftPush(V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer length() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<V> range(int start, int end) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer remove(int i, Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPop() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer rightPush(V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trim(int start, int end) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Default {@link KeyBound} implementation.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultKeyBound<K> implements KeyBound<K> {
|
||||
|
||||
private final K key;
|
||||
|
||||
public DefaultKeyBound(K key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package org.springframework.datastore.redis.core;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface RedisKeyedStore<K> {
|
||||
public interface KeyBound<K> {
|
||||
|
||||
/**
|
||||
* Returns the key associated with this store.
|
||||
@@ -44,7 +44,7 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class RedisTemplate<K, V> extends RedisAccessor {
|
||||
public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperations<K, V> {
|
||||
|
||||
private boolean exposeConnection = false;
|
||||
private RedisSerializer keySerializer = new StringRedisSerializer();
|
||||
@@ -179,4 +179,53 @@ public class RedisTemplate<K, V> extends RedisAccessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// RedisOperations
|
||||
//
|
||||
|
||||
@Override
|
||||
public Object exec() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundListOperations<K, V> forList(K key) {
|
||||
return new DefaultBoundListOperations<K, V>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getSet(K key, V newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V increment(K key, int delta) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListOperations<K, V> listOps() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multi() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(K key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user