Although I couldn’t find anything, I thought I would double check if memcache transactions are supported?
If not, then what I'm betting is the likely answer, then what is the correct method for working with memcache in a transactional environment? Didn't you have to read from the database every time you plan to update, even if the data is in the cache, just so you can set your locks? For example, a script that updates some data would look like this:
- TO BEGIN; SELECT ... FOR UPDATE;
- Calculate ...
- UPDATE TABLE ...;
- Refresh Cache
- COMMIT;
I think you need to update the cache after running your update request, if you are at a dead end and you need a rollback. But you must also update the cache before committing, in case any other thread expects to read your data, and may accidentally update it with a cache of even newer data to you, as a result of which your obsolete data will be overwritten.
Is this the correct sequence of steps? Is there any way not to get into db for reading to update?
source share