Skip to content

Cache Invalidation Performance #3137

@mmonetha-sobis

Description

@mmonetha-sobis

Hi, at my company, we've encountered some issues connected to our cache invalidation logic.

For each cache entry that should be invalidated

  • we iterate over the cache entry set, which leads to the value to be deserialized as well
  • remove every cache entry, whose key matches the key that should be invalidated

We refactor our implementation that

  • the keys that should be invalidated are gathered beforehand
  • get invalidated using removeAll instead of remove

Unfortunately the performance appears to be unchanged.

We then started checking the ehcache code base and realized that both operations (remove and removeAll) also deserialize the cache entry's value everytime either operation is called.

  1. Are our observations correct? Doesn't it matter - performance wise, wether one iterates over the cache entries himself and removes them via cache.remove() vs gathering all keys beforehand and removing them via cache.removeAll()
  2. Is there a way to invalidate cache entries without deserializing the cache entry's value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Unprioritized

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions