-
Mar 23rd, 2012, 01:59 AM
#1
Need help to work with hash set using spring data & redis (For Caching Implementation
Hi Guys,
Currently am working on implementing caching using Spring DATA & Redis.
Requirement:
-- I need to store serialized domains in the redis with help of Spring DATA.
-- I will have unique key for each domain which am gonna store.
-- I need to handle the expire time for each key as well, this will change based on what am gonna store, so of them will persist until we manually remove it from the store.
HSET noceCache nodeid:<node-id> <serialized-object>
"nodeid:<node-id>" should have expire logic.
App will get the object from cache by the command:
HGET noceCache nodeid:<node-id>
Any thought about this implementation, any suggestions?
If somebody can post code snippet for me that will be great, am not getting much documentation on Redis Spring DATA.
Thanks,
vj
Last edited by vijaymohanp; Mar 23rd, 2012 at 02:03 AM.
-
Mar 25th, 2012, 12:58 PM
#2
Hi Vijay,
You may always use RedisCallback to access low level actions.
t should be something like this
redisTemplate.execute(new RedisCallback<Object>() {
public Object doInRedis(RedisConnection connection) throws DataAccessException {
...
// remove this key after a while.
connection.expire(key.getBytes(), 300);
}
});
Thanks,
Artur
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules