Sunday, May 28, 2017

Re: Should I store offline calculation results in the cache?

On Saturday 27 May 2017 12:25:17 Antonis Christofides wrote:

 

> The question is where to store the results of the calculation. I

> thought that since they are re-creatable, the cache would be the

> appropriate place. However, there is a difference with the more

> common use of the cache: they are re-creatable, but they are also

> necessary. You can't just go and delete any item in the cache. This

> will cripple the website, which expects to find the calculation

> results in the cache.

 

What you're describing is not a cache, but a key/value store. A cache knows how to obtain content that is not in there.

 

Since you're offloading the calculation, you should not delete the old contents till the new one can be written. Swapping contents should be atomic, block reads and fast.

 

Another strategy is two have 2 for 1 entry. When updating one, lock it. Async readers go for the 2nd. Unlock, lock+write second and you're done.

This can be done with one store and 2 keys or - in a larger environment - with replicated stores, where things pretty much work automagically.

--

Melvyn Sopacua

No comments:

Post a Comment