My ROR project is currently utilizing memcached (3 nodes) on AWS elasticached to circumvent reading from the database. When trying to delete the key, it seems like Rails or Memcached is often only deleting the key on one or a few of the nodes as reading from the cache returns stale data.
Are there any configurations on rails or memcached that would prevent this or retry a key deletion if it fails on a node?
My other option is adding a version number to the rails key which I'll do if there's no better solution.
Have you reviewed the documentation? The Guide docu for Fragment Caching and ActiveSupport::Cache::MemCacheStore will probably touch on what's misconfigured.
Memcached should be automatically deleting old cache files, so it sounds like you are manually managing expiration; depending on what you're doing, it could be good to set a default expiration as a failsafe. You may need to add additional servers to your cache store config or ensure
MEMCACHE_SERVERSis being updated (it's probably best to just maintainMEMCACHE_SERVERSas a shared source of truth, as both rails + the Dalli::Client Server Configuration will look for it). Memcached servers are independent of one another and have no way to communicate; they rely on the Memcached client to send parallel requests to all the relevant servers, so if the deletions are happening in a way that circumvents the client it could also cause the issue you're describing.