Memcached (reads memkey) is a system for caching various objects in RAM. Will significantly reduce the load on the database or file system and speed up the site, due to the fact that working with memory is faster than with the database or files. As far as I remember, it was developed for LJ, and now it is used on almost all projects with a large number of users. It is launched by a separate server.
If you are going to make your startup, I advise you to pay close attention to this technology. Due to caching, you can significantly reduce the number of database queries.
For PHP, there is a special
PECL module (that is, it is not included with PHP, you need to download and compile separately). I also think there are ready-made modules for
Perl, Python (Django), Ruby (RoR) and other languages .
')
The memkesh API itself has only basic functions: server selection, connection and disconnect, adding, deleting, updating and receiving an object, increment and direction. For each object, a lifetime is set, from 1 second to infinity. When the memory is full, older objects are automatically deleted. For PHP, there are also ready-made libraries for working with memcs, which provide additional functionality.
The basic algorithm for working with memkesh is the following - it accesses the memkesh server for the object, if it is, then we take it. If not, then we access the database (or where else you can store data there), create an object, give it to the user and add it to the memkey, so that we can read it during the next call.
In memkesh it makes sense to store only the frequently requested data. If an object is requested from you once a week, then most likely the best is to use the file cache. Although it also depends on the project architecture.
Now on one of my projects (dating site) I am trying to use memokes to
implement the user status display online or offline. .