List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback
RedisCallback
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Indicates whether the current connection is subscribed (to at least one channel) or not. * /* w ww .j a va2s . c om*/ * @return true if the connection is subscribed, false otherwise */ public static boolean isSubscribed() { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.isSubscribed(); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Indicates whether the current connection is subscribed (to at least one channel) or not. * //from www . java2 s. co m * @return true if the connection is subscribed, false otherwise */ public boolean isSubscribed() { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.isSubscribed(); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Returns the current subscription for this connection or null if the connection is not subscribed. * //from w w w. j a v a 2 s . co m * @return the current subscription, null if none is available */ public static Subscription getSubscription() { return redisTemplate.execute(new RedisCallback<Subscription>() { @Override public Subscription doInRedis(RedisConnection redis) throws DataAccessException { return redis.getSubscription(); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Returns the current subscription for this connection or null if the connection is not subscribed. * /*from ww w . j a va2s . c o m*/ * @return the current subscription, null if none is available */ public Subscription getSubscription() { return redisTemplate.execute(new RedisCallback<Subscription>() { @Override public Subscription doInRedis(RedisConnection redis) throws DataAccessException { return redis.getSubscription(); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Publishes the given message to the given channel. * /*from www .j a v a 2 s. c o m*/ * @param channel the channel to publish to * @param message message to publish * @return the number of clients that received the message */ public static Long publish(byte[] channel, byte[] message) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.publish(channel, message); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Publishes the given message to the given channel. * //from w w w .j a v a 2 s .c om * @param channel the channel to publish to * @param message message to publish * @return the number of clients that received the message */ public Long publish(byte[] channel, byte[] message) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.publish(channel, message); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Subscribes the connection to the given channels. Once subscribed, a connection enters listening mode and can only * subscribe to other channels or unsubscribe. No other commands are accepted until the connection is unsubscribed. * <p>/*w w w.j a v a 2s . c o m*/ * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param channels channel names */ public static void subscribe(MessageListener listener, byte[]... channels) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.subscribe(listener, channels); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Subscribes the connection to the given channels. Once subscribed, a connection enters listening mode and can only * subscribe to other channels or unsubscribe. No other commands are accepted until the connection is unsubscribed. * <p>//from ww w . ja v a2s. c om * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param channels channel names */ public void subscribe(MessageListener listener, byte[]... channels) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.subscribe(listener, channels); return null; } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Subscribes the connection to all channels matching the given patterns. Once subscribed, a connection enters * listening mode and can only subscribe to other channels or unsubscribe. No other commands are accepted until the * connection is unsubscribed.//w w w .jav a2 s . com * <p> * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param patterns channel name patterns */ public static void pSubscribe(MessageListener listener, byte[]... patterns) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.pSubscribe(listener, patterns); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Subscribes the connection to all channels matching the given patterns. Once subscribed, a connection enters * listening mode and can only subscribe to other channels or unsubscribe. No other commands are accepted until the * connection is unsubscribed.//from w w w. ja va2 s . co m * <p> * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param patterns channel name patterns */ public void pSubscribe(MessageListener listener, byte[]... patterns) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.pSubscribe(listener, patterns); return null; } }); }