I am trying to understand the Simple Spring Memcached but have stuck with below mentioned.
What is the difference between:
- @ReadThroughSingleCache, @ReadThroughMultiCache and @ReadThroughAssignCache
- @UpdateSingleCache, @UpdateMultiCache and @UpdateAssignCache
- @InvalidateSingleCache, @InvalidateMultiCache and @InvalidateAssignCache
Also how does update work. If I make an update on a namespace with a certain key, does it go and execute all read*cache methods within the same namespace and using the same key. If yes, then would it work for multiple server applications.
For example in a certain scenario a user's points(for something) are cached Application 1
@ReadThroughSingleCache(namespace="userPoints")
public Integer getUserPoints(@ParamterKeyValueProvide String userId){
}
In another scenario from a different application(a background scheduler may be) following method is called: Application 2
UpdateThroughSingleCache(namespace="userPoints")
public void updateUserPoints(@ParameterKeyValueProvider String userId, Integer newPoints)
{
//make database update
}
My question is that if the namespace("userPoints") had a cache entry for userId("1234") as 50 points initially and the update method is called with ("1234",100) how would the cache know the logic that the entry for "1234" has to updated with 100 points.
Either it should use the return value and update it with the old value(return type needs to be changed then) or if the update was "write through" the read method should be called with the direct logic of db look up and then updating the cache... but how does application 2 notify application 1 of the update.