Can the same object cached with different keys?

148 views
Skip to first unread message

Suresh Senanayaka

unread,
Sep 22, 2023, 3:33:26 AM9/22/23
to ehcache-users
Can the same object cached with different keys?
So that if we remove the object with one key will it get removed automatically with the other key as well?
can we use composite keys or regular expressions for the keys? 
I am using pure Ehcache (without Sprint or Hibernate)

/Suresh

Chris Dennis

unread,
Sep 22, 2023, 9:11:37 AM9/22/23
to ehcach...@googlegroups.com

No, you cannot have a value mapped to multiple keys such that when one mapping is removed, the other gets removed too. For an in-heap referential cache you could introduce state (or wrap) to represent the liveness of the value, and just check it outside. The mapping wouldn’t get removed, but since the mappings share the object they would both see the state mutation that marked the object as “removed”.

 

Regarding composite keys and/or regular expressions for keys you’ll have to be more explicit. What exact behavior would you be expecting?

 

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/2cc6c2e1-1c91-4415-9941-1e52839b686fn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages