convertAndSend returns the nr of targeted channels

This commit is contained in:
Costin Leau
2013-01-24 19:11:01 +02:00
parent d01f13acfa
commit b35f6a3c5d
2 changed files with 6 additions and 7 deletions

View File

@@ -117,7 +117,7 @@ public interface RedisOperations<K, V> {
List<Object> exec();
// pubsub functionality on the template
void convertAndSend(String destination, Object message);
Long convertAndSend(String destination, Object message);
// operation types

View File

@@ -484,17 +484,16 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
}
public void convertAndSend(String channel, Object message) {
public Long convertAndSend(String channel, Object message) {
Assert.hasText(channel, "a non-empty channel is required");
final byte[] rawChannel = rawString(channel);
final byte[] rawMessage = rawValue(message);
execute(new RedisCallback<Object>() {
return execute(new RedisCallback<Long>() {
public Object doInRedis(RedisConnection connection) {
connection.publish(rawChannel, rawMessage);
return null;
public Long doInRedis(RedisConnection connection) {
return connection.publish(rawChannel, rawMessage);
}
}, true);
}
@@ -511,7 +510,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
return execute(new RedisCallback<Long>() {
public Long doInRedis(RedisConnection connection) {
return Long.valueOf(connection.ttl(rawKey));
return connection.ttl(rawKey);
}
}, true);
}