CodeIgniter Forums

Full Version: Extending redis library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried extending the redis library without any success.

Error: Severity: error --> Exception: Class 'CI_Cache_redis' not found /var/www/vhosts/***.net/***.net/application/libraries/MY_redis.php 5

Redis library is loaded and functional, just extending seems not possible.

PHP Code:
<?php

 defined
('BASEPATH') OR exit('No direct script access allowed');

class 
MY_redis extends CI_Cache_redis {
    function __construct(){
         parent::self;
    }

    public function publish($channel$message) {
        $this->_redis->publish($channel$message);
    }

    public function __destruct() {
        if ($this->_redis) {
            $this->_redis->close();
        }
    }

Out of the box, database classes can not be extended or replaced with your own classes as all other classes can. In other words, the MY_ convention does not apply to the database files.

I think you would have to extend the CI_Loader class and/or register an autoloader that can locate db driver files.