📜 ⬆️ ⬇️

Codeigniter - we carry out sessions in Memcached

Good day, habroskoobschestvo!

When it comes to optimizing a web application, then the fight goes for every request.
Therefore, finally got his hands to optimize and work with the sessions. Previously, everything was stored in the database:

$config['sess_use_database'] = TRUE;

Session settings can be called standard, with the exception of the table name.
')
After repeatedly viewing the profiler, it was decided to bring all the work with the sessions into Memcached.
What for? Yes, at least in order to get rid of unnecessary updates and selektov when generating the page.

What was done? The MY_Session class was written, overriding the key methods of the standard class for working with sessions.

Modified methods:
The essence of the changes is only to verify that we use - the DBMS or Memcached, and, accordingly, where to get and where to write the session data.

Some clarifications - in my case, the session operation option via memcached was not transferred to the common config, i.e. it starts working with sess_use_database = FALSE

The settings for the connection with memcached are made in the eponymous config - config / memcached.php.

Work with memcached-server occurs through the wrapper, decorated in the form of a model.

All files can be taken here .

Source: https://habr.com/ru/post/79990/


All Articles