I'm running an application on AWS Elastic Beanstalk PHP 7.3 running on 64bit Amazon Linux/2.9.12 and I've recently starting getting the following error -
Call to undefined method Redis::delete()
I have a Redis cache configuration which I'm able to write to and read. But then when I try to delete the same, I get the above error. This was not happening before. I have correctly configured the cache like below
Cache::config('1min', [
'engine' => CACHE_ENGINE,
'server' => CACHE_HOST,
'port' => CACHE_PORT,
'prefix' => CACHE_PREFIX,
'duration'=>'+1 minute'
]);
And I'm able to execute the following actions
Cache::write('cache1', 'value', '1min');
Cache::read('cache1', '1min');
without any errors. It's only when I try to delete the key using the following command
Cache::delete('cache1', '1min');
that I'm getting the above error.
I'm using phpredis which I install via .ebextensions. I'm downloading the package via this link -
https://github.com/phpredis/phpredis/archive/develop.zip -O phpredis.zip
Upon doing some research, I found that the delete function in Redis.php is deprecated as is soon going to be deleted. When I change the function call in the RedisEngine.php file (this is a CakePHP library file which gets downloaded as a dependency via composer) on line 176 from
public function delete($key) {
return $this->_Redis->delete($key) > 0;
}
to
public function delete($key) {
return $this->_Redis->del($key) > 0;
}
the Cache delete works correctly. This was not happening before. If I can get some assistance with this at the earliest that would be much appreciated.
Thank you!