Announcement Announcement Module
Collapse
No announcement yet.
Need help to work with hash set using spring data & redis (For Caching Implementation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 02:03 AM.

  • #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

    Comment

    Working...
    X