I've been trying to change the cache driver (CACHE_DRIVER
) from file to memcached in production (shared host) where Memcached is set correctly and available according to phpinfo. Running still on Laravel 7.4.x
So far I've done the following:
CACHE_DRIVER=file
to CACHE_DRIVER=memcached
;<?PHP
'stores' => [
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), // not required I think?...
'sasl' => [
env('MEMCACHED_USERNAME'), // not required I think?...
env('MEMCACHED_PASSWORD'), // not required I think?...
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000, // Ok
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'), // set like in phpinfo
'port' => env('MEMCACHED_PORT', 11211), // not required I think?...
'weight' => 100, // Ok
],
],
],
// ....
],
php artisan config:clear
and php artisan cache:clear
;cache()->has('countries')
and its false;CACHE_DRIVER=file
and started over. Result for cache()->has('countries')
and its trueEither probably I'm missing something in the process, yet in local it's running on Memcached and for performance improvement, I'm trying to change it in production.
Thanks in advance for any inputs that might help me to solve this issue.
I won't delete the question (answering here) as it may help others facing the same problem on shared hostings.
As @apokryfos mentioned the extension may be there but the Memcached server might not be available in all shared hostings, which is my case.
If you have your projects on shared hosting and want to use Memcached, contact their support and ask if your plan contemplates the Memcached server. Otherwise, use other cache systems, namely and ultimately the file cache.