The first of my posts on how to test the cache and the cache expiration policy. Click here for what you should do before reading this post. It explains the different policies and what you need in advance to test.
The absolute expiration policy is one of the easiest policies to test. There are two basic test cases:
- The object is cached until expiration
- The object is refreshed after expiration
The object is cached until expiration:
- For my example I’ll use five minutes relative from creation as the cache expiration time
- Place an object in the cache (the cache timer starts now)
- Update the object (this may involve changing a web-page or updating a record in the database, whatever you do, do not access the object such that it will be cached or update its cache)
- Wait four minutes
- Access the object You should get the cached version and not the updated version
The object is refreshed after expiration:
- For my example I’ll use five minutes relative from creation as the cache expiration time
- Place an object in the cache (the cache timer starts now)
- Update the object (this may involve changing a web-page or updating a record in the database, whatever you do, do not access the object such that it will be cached or update it’s cache.)
- Wait five minutes.
- Access the object. You should get the updated version and not the cached version
As you can see that it is not complicated. The only hard part is making sure you can update your record within the cache timeout. Naturally this only covers the policy and not the rest of the cache behaviour. Such behaviour is common regardless of the expiration policy so I’ll save that for a seperate post.
|
|
Ryan Boucher is a Software Inquisitor and is passionate about it. You can find a whole raft of articles and anecdotes about software testing and other topics he gets excited about. |
| Tags |