I am attempting to update a value in my application, lets call it a Foo object. Foo is immutable as a java object but can be updated in the database via a Hibernate entity. I am accessing Foo objects by calling a loading cache overlay (Guava Cache as the implementation) that loads the value from the database when it isn't present. In addition, there will be few writes but many reads to Foo objects, though concurrent writes are possible.
What is the best way to update a Foo object? Locking the cache on update? Some other structural design?
Note, there is definitely information on this subject out in the vast Internets, but I read so much of it trying to figure this out that I confused myself. I am currently leaning towards a ReentrantLock on the update method of the cache implementation class, but it seems like there should be a better way.