0

Net web api developer and i want to know if im working correctly. Im saving a changeable objects into the cache. Other developers on my team said only static data should be stored in the cache. So i wanted to know if only static data need to be store in cache or there's another right way to do it. Thanks.

3
  • I would say your question is too broad. The golden rule when working with cache is to treat any data in cache as old data. For example you don't want to show data about, let's say, stocks exchange rates from cache, because stocks changes quite frequently
    – Alex
    Commented Dec 8, 2016 at 8:59
  • _saving a changeable objects into the cache -does that solve you purpose? Commented Dec 8, 2016 at 9:02
  • 1
    @Goor Lavi, there are some of strategies to deal with changeable data. You can try a caching policy to refresh data after an interval or apply kind of active caching mechanism (or pushing approach, whatever) to force cached data to be reloaded (or just be updated the changes) whenever any changes happen.
    – Bob Dust
    Commented Dec 8, 2016 at 9:03

1 Answer 1

0

I use caching for changeable objects because they take a reasonable amount of time to generate, although the frequency of their changing varies.

There are a couple of things which I do to try and make sure the data is always valid.

On the cached item I put a policy which will keep the item in cache for say 15 minutes, and make the expiration time sliding. This keeps the used items in cache but drops less used items.

I also have cache eviction end points on the API, and the process which updates the data in the database calls the endpoint once the process has been complete. The items which have been updated are then removed from the cache and hence rebuilt the next time they are requested.

In the end I think it all boils down to how long it takes to get the object you are trying to return, and whether the delay to generate it is acceptable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.