0

I have some PHP pages using a common stateless component that computes file hashes on demand and keeps them for future recall (to avoid multiple computations).

I would like to use the fact that PHP is not shutting down between requests to keep the data available if memory is not full.

The process is stateless so I have no problem with PHP shutting down or deleting the object, and saving/reloading the state from disk is slower than recomputation (not all script uses the same file hashes, so saving/loading them all is not good).

Is there some way to store an object instance in PHP across multiple script calls without saving on disk? If the data is deleted or a new object is created for separate threads it is not a problem, the methods are all pure.

Nahid Islam
  • 193
  • 1
  • 5
  • 15
DarioDF
  • 301
  • 1
  • 10
  • Does this answer your question? [How to use memcache with php](https://stackoverflow.com/questions/4779523/how-to-use-memcache-with-php) – Progman Mar 22 '20 at 11:15
  • This would mean having and connecting to another process, context switching and having hardcoded identifiers (which per se is not bad) and another dependency, while php is running in bg anyway due to fastcgi, I thought there was a shared memory space inside php itself, thanks anyway, for larger data it is a good idea, my blocks are small and there are may so the calls would be slower with memcache – DarioDF Apr 17 '20 at 12:19

0 Answers0