Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

permanent storage of PHP variables?

Is it possible to store permanent variables in PHP, i.e. final unmodifiable variables, but which can be read by all users requesting a page?

E.g. I would need to use a dictionary on a page, starting with a big (invariant) word list. What is the best way to do this?

  • Converting the word list to a tree on-the-fly on every page load is a total waste of compute resources and requires several seconds per page load.
  • Putting the tree in the file system as subfolders and use file_exists() is fast enough but uses 4KB per word, which is a total waste of disk space.
  • Putting the words in a database is unworkable as I need thousands of lookups per page load.

What would be the proper way to store this dictionary?

like image 959
user1111929 Avatar asked Feb 19 '23 01:02

user1111929


1 Answers

memcached is very popular in php as a way to keep stuff in memory that can be accessed by many processes http://php.net/manual/en/book.memcached.php

a similar solution could be to use an sqlite shared memory database http://www.sqlite.org/inmemorydb.html

like image 71
goat Avatar answered Feb 28 '23 09:02

goat