I'm in need of some caching since the database isn't able to sustain a huge amount of writes without batch queries. Therefore I need to cache queries to run them in batch once a second.
Now since the only way to achieve this with PHP is to use some caching system, I thought about apcu, since it is using shared memory which is probably the fastest for this need of one cache entry per request (requests are in the thousands per second).
My main issue is finding a way of implementation that is atomic.
I thought about caching everything under the current datetime (each datetime would contain a few thousand records), then using the iterator to select and delete everything < current date time. But the read/delete wouldn't be atomic and there is no option to push to an array and reading -> modifying -> writing ain't atomic.
Do you have any tips on how I could achieve this or is there no luck with PHP?