Welcome Guest, Not a member yet? Register   Sign In
An uncaught Exception - Redis Server
#1

(This post was last modified: 03-14-2020, 12:57 AM by jreklund.)

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!
Reply
#2

(This post was last modified: 03-14-2020, 01:03 AM by jreklund.)

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.
Reply
#3

(This post was last modified: 03-14-2020, 01:12 AM by jreklund.)

(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);
    }

Reply
#4

(This post was last modified: 03-14-2020, 01:26 AM by jreklund.)

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/libra...is-caching

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

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!
Reply
#6

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
Reply
#7

(This post was last modified: 03-23-2020, 11:36 AM by jreklund.)

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
Reply
#8

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);
}

}
Reply
#9

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

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




Theme © iAndrew 2016 - Forum software by © MyBB