I have a Google guava cache that is loading data from the database and caching it using the primary key. The objects I end up creating from the database are immutable and building an object requires access to several tables. What happens in the following scenario:
- Thread 1: calls cache.load(10) and the cache is being populated based on a database primary key with value 10
- Thread 2: updates the database row with primary key 10 and so it calls cache.invalidate(10) the invalidate is called before the cache.load(10) is finished.
What does Guava Loading Cache do when invalidate(x) is called while load(x) is executing?