hazelcast / hazelcast

Hazelcast is a unified real-time data platform combining stream processing with a fast data store, allowing customers to act instantly on data-in-motion for real-time insights.
https://www.hazelcast.com
Other
6.12k stars 1.84k forks source link

Add TTL value to atomic longs #7079

Open harsha89 opened 8 years ago

harsha89 commented 8 years ago

Hi All,

It's really useful to have a option to set TTL value for hazelcast atomic longs. If not system needs to write a cleanup task to remove them. It may cause OOM. I believe it's good option to have a TTL setting as in maps.

Thanks, Harsha

pveentjer commented 8 years ago

You can use an IMap with the name of the 'atomiclong' as key. You can do all the usual operations like get/set/compareAndSet(replace) and alter (using entryprocessors). On top of that you get all the goodies from IMap like ttl.

harsha89 commented 8 years ago

Hi Pveentier,

Agreed on that. I have one question on entry processors. Can it be handle multiple updates perform in multiple nodes in the cluster? We are maintaining atomic long for distributed counter across the cluster. This more analogs to atomic log addAndGet operations. Also can updates done in asynchronous manner in map? What we notice is that, when there are large number of atomic longs to be replicate, it takes considerable time to update the instance. Hence async gives more flexibility without waiting the replicator thread.

Thanks, Harsha

jerrinot commented 8 years ago

Hello @harsha89,

entry processors on the same key are guaranteed to be atomic. You can submit 2 entry processors concurrently and they will run one-by-one (on the same key). See http://docs.hazelcast.org/docs/3.5/manual/html-single/index.html#entry-processor for details.

harsha89 commented 8 years ago

Thanks for the details. I'll check it out.

mmedenjak commented 6 years ago

Hi @harsha89 !

Have you had the chance to try out the suggestion?

z0mb1ek commented 5 years ago

@pveentjer hi. has IMap same perfomance for this like IAtomicLong ?