Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Create custom Cache Storage Driver?
  • Is it possible to create custom cache storage driver?

    I see the existing drivers are under core/classes/cache/storage and extends from Cache_Storage_Driver.

    Because I got my code from git, I want to keep core package not changed and be able update easily later.

    So is there a way I can create my custom cache storage driver under fuel/app and get it loaded and use with Cache?

    P.S. Side reason is because there is a bug Memcached connecting to Couchbase will fail on getStats(), which results having FuelException while there is no problem with Set/Get in usage.  So I want to create custom cache driver that will be use against Couchbase.
  • I found out Cache is constructing the storage driver class by calling:
    		$class = '\\Cache_Storage_'.ucfirst($config['driver']);

    // Convert the name to a string when necessary
    $identifier = call_user_func($class.'::stringify_identifier'$identifier);

    // Return instance of the requested cache object
    return new $class($identifier$config);
    So I created my couchbase.php under /fuel/app/classes/cache/storage/ and its works fine!
    Please let me know if there is better way :)
  • HarroHarro
    Accepted Answer
    Nope, that is fine, how it should be. This easy extendibility is the main reason why Fuel aliases it's classes.
  • Thanks Harro!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion