Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are different between Backend vs Frontend Cache of Zend Framework

I am implementing caching for my website which is using Zend Framework.

I look into the source code and see that:

Zend_Cache::factory()

always need two configurations of backend and frontend.

And my issue is:

I don't know why backend is set inside frontend,
and what is the difference between them?

$frontendObject->setBackend($backendObject);
return $frontendObject;

Here is the orginal source code:

public static function factory($frontend, $backend, $frontendOptions = array(), $backendOptions = array(), $customFrontendNaming = false, $customBackendNaming = false, $autoload = false)
{
    if (is_string($backend)) {
        $backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
    } else {
        if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
            $backendObject = $backend;
        } else {
            self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
        }
    }
    if (is_string($frontend)) {
        $frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, $autoload);
    } else {
        if (is_object($frontend)) {
            $frontendObject = $frontend;
        } else {
            self::throwException('frontend must be a frontend name (string) or an object');
        }
    }
    $frontendObject->setBackend($backendObject);
    return $frontendObject;
}
like image 607
vietean Avatar asked Nov 25 '25 03:11

vietean


1 Answers

The cache backend is the "cache engine" : it can be file, memcached, etc.

The cache frontend specify what kind of data will be stored in the cache (see http://framework.zend.com/manual/1.12/en/zend.cache.frontends.html)

like image 121
haltabush Avatar answered Nov 26 '25 18:11

haltabush



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!