+ add missing getOperation to bound ops interfaces
This commit is contained in:
@@ -1,47 +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.data.keyvalue.redis.core;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.data.keyvalue.redis.connection.DataType;
|
||||
|
||||
/**
|
||||
* Key operations bound to a certain value.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface BoundKeyOperations<K> extends KeyBound<K> {
|
||||
|
||||
Boolean exists();
|
||||
|
||||
void delete();
|
||||
|
||||
DataType type();
|
||||
|
||||
void rename(K newKey);
|
||||
|
||||
Boolean renameIfAbsent(K newKey);
|
||||
|
||||
Boolean expire(long timeout, TimeUnit unit);
|
||||
|
||||
Boolean expireAt(Date date);
|
||||
|
||||
Long getExpire();
|
||||
|
||||
void persist();
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public interface BoundValueOperations<K, V> extends KeyBound<K> {
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
|
||||
void set(V value);
|
||||
|
||||
void set(V value, long timeout, TimeUnit unit);
|
||||
|
||||
@@ -64,4 +64,9 @@ class DefaultBoundValueOperations<K, V> extends DefaultKeyBound<K> implements Bo
|
||||
public Boolean setIfAbsent(V value) {
|
||||
return ops.setIfAbsent(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,7 @@ public interface ListOperations<K, V> {
|
||||
|
||||
V rightPop(K key, long timeout, TimeUnit unit);
|
||||
|
||||
void rightPopAndLeftPush(K sourceKey, K destinationKey);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
private RedisSerializer hashKeySerializer = new SimpleRedisSerializer();
|
||||
private RedisSerializer hashValueSerializer = new SimpleRedisSerializer();
|
||||
|
||||
// cache singleton objects (where possible)
|
||||
private final ValueOperations<K, V> valueOps = new DefaultValueOperations();
|
||||
private final ListOperations<K, V> listOps = new DefaultListOperations();
|
||||
private final SetOperations<K, V> setOps = new DefaultSetOperations();
|
||||
private final ZSetOperations<K, V> zSetOps = new DefaultZSetOperations();
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RedisTemplate</code> instance.
|
||||
*
|
||||
@@ -567,7 +573,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
|
||||
@Override
|
||||
public ValueOperations<K, V> getValueOps() {
|
||||
return new DefaultValueOperations();
|
||||
return valueOps;
|
||||
}
|
||||
|
||||
private class DefaultValueOperations implements ValueOperations<K, V> {
|
||||
@@ -722,11 +728,16 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return RedisTemplate.this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListOperations<K, V> getListOps() {
|
||||
return new DefaultListOperations();
|
||||
return listOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -919,7 +930,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
|
||||
@Override
|
||||
public SetOperations<K, V> getSetOps() {
|
||||
return new DefaultSetOperations();
|
||||
return setOps;
|
||||
}
|
||||
|
||||
private class DefaultSetOperations implements SetOperations<K, V> {
|
||||
@@ -1079,7 +1090,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
|
||||
@Override
|
||||
public ZSetOperations<K, V> getZSetOps() {
|
||||
return new DefaultZSetOperations();
|
||||
return zSetOps;
|
||||
}
|
||||
|
||||
private class DefaultZSetOperations implements ZSetOperations<K, V> {
|
||||
|
||||
@@ -30,8 +30,6 @@ public interface SetOperations<K, V> {
|
||||
|
||||
void diffAndStore(K key, K destKey, Collection<K> keys);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
|
||||
Set<V> intersect(K key, Collection<K> keys);
|
||||
|
||||
void intersectAndStore(K key, K destKey, Collection<K> keys);
|
||||
@@ -50,4 +48,5 @@ public interface SetOperations<K, V> {
|
||||
|
||||
Long size(K key);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
}
|
||||
|
||||
@@ -43,4 +43,6 @@ public interface ValueOperations<K, V> {
|
||||
Collection<V> multiGet(Collection<K> keys);
|
||||
|
||||
Long increment(K key, long delta);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user