Skip to content

DATAREDIS-716 - Add support for OBJECT REFCOUNT, ENCODING and IDLETIME. #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
<version>2.1.0.DATAREDIS-716-SNAPSHOT</version>

<name>Spring Data Redis</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
*/
package org.springframework.data.redis.connection;

import java.util.*;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -1079,6 +1089,33 @@ public List<byte[]> sort(byte[] key, SortParameters params) {
return convertAndReturn(delegate.sort(key, params), identityConverter);
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#encoding(byte[])
*/
@Override
public ValueEncoding encodingOf(byte[] key) {
return convertAndReturn(delegate.encodingOf(key), identityConverter);
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#idletime(byte[])
*/
@Override
public Duration idletime(byte[] key) {
return convertAndReturn(delegate.idletime(key), identityConverter);
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#refcount(byte[])
*/
@Override
public Long refcount(byte[] key) {
return convertAndReturn(delegate.refcount(key), identityConverter);
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisSetCommands#sPop(byte[])
Expand Down Expand Up @@ -1295,7 +1332,7 @@ public Double zIncrBy(byte[] key, double increment, byte[] value) {
return convertAndReturn(delegate.zIncrBy(key, increment, value), identityConverter);
}

/*
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisZSetCommands#zInterStore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Aggregate, org.springframework.data.redis.connection.RedisZSetCommands.Weights, byte[][])
*/
Expand Down Expand Up @@ -1556,7 +1593,7 @@ public Double zScore(byte[] key, byte[] value) {
return convertAndReturn(delegate.zScore(key, value), identityConverter);
}

/*
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisZSetCommands#zUnionStore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Aggregate, org.springframework.data.redis.connection.RedisZSetCommands.Weights, byte[][])
*/
Expand Down Expand Up @@ -2389,6 +2426,33 @@ public List<String> sort(String key, SortParameters params) {
return convertAndReturn(delegate.sort(serialize(key), params), byteListToStringList);
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#encoding(java.lang.String)
*/
@Override
public ValueEncoding encodingOf(String key) {
return encodingOf(serialize(key));
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#idletime(java.lang.String)
*/
@Override
public Duration idletime(String key) {
return idletime(serialize(key));
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#refcount(java.lang.String)
*/
@Override
public Long refcount(String key) {
return refcount(serialize(key));
}

/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#sPop(java.lang.String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -222,6 +223,27 @@ default Long sort(byte[] key, SortParameters params, byte[] sortKey) {
return keyCommands().sort(key, params, sortKey);
}

/** @deprecated in favor of {@link RedisConnection#keyCommands()}. */
@Override
@Deprecated
default ValueEncoding encodingOf(byte[] key) {
return keyCommands().encodingOf(key);
}

/** @deprecated in favor of {@link RedisConnection#keyCommands()}. */
@Override
@Deprecated
default Duration idletime(byte[] key) {
return keyCommands().idletime(key);
}

/** @deprecated in favor of {@link RedisConnection#keyCommands()}. */
@Override
@Deprecated
default Long refcount(byte[] key) {
return keyCommands().refcount(key);
}

// STRING COMMANDS

/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,4 +692,37 @@ default Mono<Boolean> move(ByteBuffer key, int database) {
* @see <a href="http://redis.io/commands/move">Redis Documentation: MOVE</a>
*/
Flux<BooleanResponse<MoveCommand>> move(Publisher<MoveCommand> commands);

/**
* Get the type of internal representation used for storing the value at the given {@code key}.
*
* @param key must not be {@literal null}.
* @return the {@link Mono} emitting {@link org.springframework.data.redis.connection.ValueEncoding}.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT ENCODING</a>
* @since 2.1
*/
Mono<ValueEncoding> encodingOf(ByteBuffer key);

/**
* Get the {@link Duration} since the object stored at the given {@code key} is idle.
*
* @param key must not be {@literal null}.
* @return the {@link Mono} emitting the idletime of the key of {@link Mono#empty()} if the key does not exist.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT IDLETIME</a>
* @since 2.1
*/
Mono<Duration> idletime(ByteBuffer key);

/**
* Get the number of references of the value associated with the specified {@code key}.
*
* @param key must not be {@literal null}.
* @return {@link Mono#empty()} if key does not exist.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT REFCOUNT</a>
* @since 2.1
*/
Mono<Long> refcount(ByteBuffer key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection;

import java.time.Duration;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -303,4 +304,42 @@ default Boolean exists(byte[] key) {
* @see <a href="http://redis.io/commands/restore">Redis Documentation: RESTORE</a>
*/
void restore(byte[] key, long ttlInMillis, byte[] serializedValue);

/**
* Get the type of internal representation used for storing the value at the given {@code key}.
*
* @param key must not be {@literal null}.
* @return {@link org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding#VACANT} if key does not
* exist or {@literal null} when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT ENCODING</a>
* @since 2.1
*/
@Nullable
ValueEncoding encodingOf(byte[] key);

/**
* Get the {@link Duration} since the object stored at the given {@code key} is idle.
*
* @param key must not be {@literal null}.
* @return {@literal null} if key does not exist or when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT IDLETIME</a>
* @since 2.1
*/
@Nullable
Duration idletime(byte[] key);

/**
* Get the number of references of the value associated with the specified {@code key}.
*
* @param key must not be {@literal null}.
* @return {@literal null} if key does not exist or when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @see <a href="http://redis.io/commands/object">Redis Documentation: OBJECT REFCOUNT</a>
* @since 2.1
*/
@Nullable
Long refcount(byte[] key);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection;

import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -317,6 +318,39 @@ interface StringTuple extends Tuple {
*/
Long sort(String key, SortParameters params, String storeKey);

/**
* Get the type of internal representation used for storing the value at the given {@code key}.
*
* @param key must not be {@literal null}.
* @return {@literal null} if key does not exist or when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @since 2.1
*/
@Nullable
ValueEncoding encodingOf(String key);

/**
* Get the {@link Duration} since the object stored at the given {@code key} is idle.
*
* @param key must not be {@literal null}.
* @return {@literal null} if key does not exist or when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @since 2.1
*/
@Nullable
Duration idletime(String key);

/**
* Get the number of references of the value associated with the specified {@code key}.
*
* @param key must not be {@literal null}.
* @return {@literal null} if key does not exist or when used in pipeline / transaction.
* @throws IllegalArgumentException if {@code key} is {@literal null}.
* @since 2.1
*/
@Nullable
Long refcount(String key);

// -------------------------------------------------------------------------
// Methods dealing with values/Redis strings
// -------------------------------------------------------------------------
Expand Down
Loading