Say I have something cached for 30s, the db request that generates what is cached takes 2s and I’m getting 100 requests per second, what will happen when the cache needs refreshing?
I suspect my db gets hit 200 times. What I would want to happen is to let the first one through, but then tell the others to go back to the cache, so basically after 30s the first try on the cache says nothing here but then the remaining get given what was previously there until the one that got let through updates it.
Do I have to do this on an application level or can memcache be configured to do this?
You will need to build this logic within your applications. When the item is not found within memcached, simply retrive it from the database, and create a new item within the cache. After the item expires, you’ll need to re-cache the item from the database.