Skip to content

Commit

Permalink
Switch from PHP memcached client to CakePHP's
Browse files Browse the repository at this point in the history
This is a first step to switch to storing PHP session
data into the database in a seamless way.

Setting php_admin_value[session.save_handler] in php.ini has the effect
of preventing changing session.save_handler at run time. We need to get
rid of that, so that we can use a custom session handler. Next, we’ll
be able to switch the session handler from a simple code update.

The memc.sess.key. prefix seems to be the default prefix used by PHP,
which I discovered using tcpdump.

Refs #3160.
  • Loading branch information
jiru committed Feb 4, 2025
1 parent 3206771 commit 4d57faf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 0 additions & 3 deletions ansible/roles/setup_php/templates/tatoeba.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ php_admin_value[opcache.revalidate_path] = 0
php_admin_value[opcache.validate_timestamps] = 2
php_admin_value[opcache.max_file_size] = 0

php_admin_value[session.save_handler] = memcached
php_admin_value[session.save_path] = "localhost:11211"

php_admin_value[url_rewriter.tags] = "a=href,area=hrea,frame=src,input=src,form=fakeentry"
14 changes: 13 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@
'duration' => '+1 years',
'url' => env('CACHE_CAKEROUTES_URL', null),
],

'memcached' => [
'className' => 'Cake\Cache\Engine\MemcachedEngine',
'host' => 'localhost',
'port' => 11211,
'duration' => 120 * 60, // same as Session.timeout, converted to seconds
'prefix' => 'memc.sess.key.',
'serialize' => 'igbinary',
],
],

/**
Expand Down Expand Up @@ -404,7 +413,10 @@
* To use database sessions, load the SQL file located at config/schema/sessions.sql
*/
'Session' => [
'defaults' => 'php',
'defaults' => 'cache',
'handler' => [
'config' => 'memcached',
],
'timeout' => 120,
],
];

0 comments on commit 4d57faf

Please sign in to comment.