CodeIgniter Forums
An uncaught Exception - Redis Server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: An uncaught Exception - Redis Server (/showthread.php?tid=75763)

Pages: 1 2


An uncaught Exception - Redis Server - ravikantgyanwave - 03-14-2020

When I try to add my codeignitor project with Redis Server, I have received a error.
Code:
Type: Error    
    Message: Call to a member function sRemove() on null    
    Filename: C:\wamp64\www\services\system\libraries\Cache\drivers\Cache_redis.php    
    Line Number: 196    
    Backtrace:    
    File: C:\wamp64\www\services\application\controllers\Redis.php
Line: 6
Function: save    
    File: C:\wamp64\www\services\index.php
Line: 315
Function: require_once

Please help me, what is the issue!


RE: An uncaught Exception - Redis Server - jreklund - 03-14-2020

What version of CI 3.x are you on? Have you upgraded to the latest version?
How are you connecting to your Redis server?
Have you enabled Redis driver in PHP?
What PHP version are you using?
What Redis version are you using?
And last but not least; show us the code that give you that error.


RE: An uncaught Exception - Redis Server - ravikantgyanwave - 03-14-2020

(03-14-2020, 01:02 AM)jreklund Wrote: What version of CI 3.x are you on? Have you upgraded to the latest version?
How are you connecting to your Redis server?
Have you enabled Redis driver in PHP?
What PHP version are you using?
What Redis version are you using?
And last but not least; show us the code that give you that error.

I am new to CI,
I am using below code in controller class Redis.
I am using Wamp Server and Install redis via Docker.

PHP Code:
class Redis extends CI_Controller{
    public function 
index(){
        
$this->load->driver('cache'); 
        
$this->cache->redis->save('foo''bar',70);
    }




RE: An uncaught Exception - Redis Server - jreklund - 03-14-2020

Based on that, you have a lot of things that needs to be done. If that's the only thing you have done so far.

Docker:
1. Configure Redis (what ports are used, ip-adress, username/password etc) https://redis.io/documentation
2. Open ports so you can connect to your docker (No idea, won't even try to figure this out myself)

Windows:
1. Install Redis PHP extension (in wamp64); https://pecl.php.net/package/redis/5.2.0/windows
1.1. Download the Thread Safe x64 depending on PHP version
1.2. Place it in e.g. C:\wamp64\bin\php\php7.3.12\ext
1.3. Press the Wampicon -> PHP -> php.ini
1.4. Place extension=php_redis.dll alongside all other extension=.
1.5. Restart wamp64
1.6. Visit http://localhost/?phpinfo=-1 to see if it's loaded
2. Configure CodeIgniter to connect to your server https://codeigniter.com/user_guide/libraries/caching.html?#redis-caching

I'm afraid I can't go into any more details than this. As I haven't used your specifications.


RE: An uncaught Exception - Redis Server - ravikantgyanwave - 03-23-2020

I have installed redis and when I start redis-cli then it show Local IP 127.0.0.1 and port is
6379. When I type PING it respond PONG and set & Get value is also working properly on CLI
window!

I will try to installed PHP extension and other steps & back to you!


RE: An uncaught Exception - Redis Server - ravikantgyanwave - 03-23-2020

Step 1 - Donwload from Below Link
https://pecl.php.net/package/redis/5.2.0/windows
Step 2 - Extract and copy dll file in C:\wamp64\bin\php\php7.3.12\ext location
Step 3 - Add extension in php.ini with code ;extension=php_redis.dll
Step 4 - Restarted wamp64
Step 5 - But did not find anything related to redis here - Visit http://localhost/?phpinfo=-1
Let me know please, Thanks


RE: An uncaught Exception - Redis Server - jreklund - 03-23-2020

Hi, you should remove ; from ;extension=php_redis.dll. As you have commented out your redis extension, and it won't load it in PHP.

Wrong:
Code:
;extension=php_redis.dll

Right:
Code:
extension=php_redis.dll



RE: An uncaught Exception - Redis Server - ravikantgyanwave - 03-23-2020

Thanks a lot so far,
I have checked http://localhost/?phpinfo=-1 and showing redis server configuration
I have restart swamp and now I have got error which is in below screenshot!
https://prnt.sc/rlmked

Here is code of Controller
class Redis extends CI_Controller{

public function index(){
$this->load->driver('cache');
$this->cache->redis->save('foo', 'bar',70);
}

}


RE: An uncaught Exception - Redis Server - jreklund - 03-24-2020

Your need to choose another class name, as the error states.
Code:
class MyRedis extends CI_Controller



RE: An uncaught Exception - Redis Server - ravikantgyanwave - 03-24-2020

Thanks, I have done.
Redis cache driver sRemove() is deprecated I have used sRem to replace sRemove()
ThankYou Very Much!