Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

How to clear elements from cache after a particular interval

Hi,

I have a requirement as below:

  1. I am storing the item in localCacheSpace
  2. Once it is stored, it should remove from cache after 2 mins of interval. (Only the particular element)

How to achieve this using gigaspace? Is there any cache evict method that will run after some particular time frame or we need to remove the element manually?

Please provide your valuable suggestions. Thanks in advance.

Edited by: Gopinathan Mani on Feb 25, 2013 6:16 AM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=4039]{quote}

asked 2013-02-25 06:16:03 -0600

get4gopim gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Gopinathan,

The second parameter of the write operation determines the time to live (in ms) of the object within the space. This will expire the object automatically.

gigaSpace.write(message1, 1000);  

See more info here.

Shay

answered 2013-02-25 09:13:00 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Thanks Shay,

I have another requirement. Instead of deleting the object from the cache after a particular sec i wanted to update the object's attribute as (active or inactive). Is there any way ?

Is there any handler to handle the expired object and update that in the cache ?

get4gopim gravatar imageget4gopim ( 2013-02-27 05:21:09 -0600 )edit

If you want to be notified when the object expired you should use the [Notify container|http://wiki.gigaspaces.com/wiki/display/XAP91/Notify+Container]. Make sure you have only the NOTIFY_LEASE_EXPIRATION used (otherwise you will be notified for other life cycle events). Returning an object from the event listener method will write the object implicitly back into the space.

Updating objects done usually by reading (via the ID , or SQL Query) and later writing these back. See some code examples [here|http://wiki.gigaspaces.com/wiki/display/XAP91/The+GigaSpace+Interface#TheGigaSpaceInterface-CodeSnippets].

Shay

shay hassidim gravatar imageshay hassidim ( 2013-02-27 08:03:27 -0600 )edit

You can also use a polling container with dynamic templates that will search for objects with old timestamp and modify them.

Eitan

eitany gravatar imageeitany ( 2013-02-27 09:37:17 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-02-25 06:16:03 -0600

Seen: 1,853 times

Last updated: Feb 25 '13