Public Member Functions | Protected Member Functions | Protected Attributes

Robo47_Cache_DoctrineAdapter Class Reference

List of all members.

Public Member Functions

 __construct ($cache, $prefix= '', $tags=array())
 getCache ()
 Get Cache.
 getPrefix ()
 Get Prefix.
 getTags ()
 Get Tags.
 setCache ($cache)
 Set Cache.
 setPrefix ($prefix)
 Set Prefix.
 setTags (array $tags=array())
 Set Tags.

Protected Member Functions

 _cacheFromRegistry ($key)
 Get Cache From Registry.
 _doContains ($id)
 Test if a cache record exists for the passed id.
 _doDelete ($id)
 Remove a cache record directly.
 _doFetch ($id, $testCacheValidity=true)
 Fetch a cache record from this cache driver instance.
 _doSave ($id, $data, $lifeTime=false)
 Save a cache record directly.
 _getCacheKeys ()
 Fetch an array of all keys stored in cache.

Protected Attributes

 $_cache = null
 $_prefix = ''
 Prefix used with all keys.
 $_tags = array()

Detailed Description

Definition at line 38 of file DoctrineAdapter.php.


Constructor & Destructor Documentation

Robo47_Cache_DoctrineAdapter::__construct ( cache,
prefix = '',
tags = array() 
)
Parameters:
Zend_Cache_Core|string $cache
string $prefix
array $tags

Definition at line 65 of file DoctrineAdapter.php.

References setCache(), setPrefix(), and setTags().

    {
        $this->setCache($cache);
        $this->setPrefix($prefix);
        $this->setTags($tags);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Cache_DoctrineAdapter::_cacheFromRegistry ( key  )  [protected]

Get Cache From Registry.

Parameters:
string $key

Definition at line 131 of file DoctrineAdapter.php.

Referenced by setCache().

    {
        if (Zend_Registry::isRegistered($key)) {
            return Zend_Registry::get($key);
        } else {
            $message = 'Registry key "' . $key .
                '" for Cache is not registered.';
            throw new Robo47_Cache_Exception($message);
        }
    }

Here is the caller graph for this function:

Robo47_Cache_DoctrineAdapter::_doContains ( id  )  [protected]

Test if a cache record exists for the passed id.

Parameters:
string $id cache id
Returns:
mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record

Definition at line 181 of file DoctrineAdapter.php.

    {
        return $this->_cache->test($this->_prefix . $id);
    }

Robo47_Cache_DoctrineAdapter::_doDelete ( id  )  [protected]

Remove a cache record directly.

This method is implemented by the cache drivers and used in Doctrine_Cache_Driver::delete()

Parameters:
string $id cache id
Returns:
boolean true if no problem

Definition at line 213 of file DoctrineAdapter.php.

    {
        return $this->_cache->remove($this->_prefix . $id);
    }

Robo47_Cache_DoctrineAdapter::_doFetch ( id,
testCacheValidity = true 
) [protected]

Fetch a cache record from this cache driver instance.

Parameters:
string $id cache id
boolean $testCacheValidity if set to false, the cache validity won't be tested
Returns:
mixed Returns either the cached data or false

Definition at line 169 of file DoctrineAdapter.php.

    {
        return $this->_cache->load($this->_prefix . $id, $testCacheValidity);
    }

Robo47_Cache_DoctrineAdapter::_doSave ( id,
data,
lifeTime = false 
) [protected]

Save a cache record directly.

This method is implemented by the cache drivers and used in Doctrine_Cache_Driver::save()

Parameters:
string $id cache id
string $data data to cache
int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
Returns:
boolean true if no problem

Definition at line 196 of file DoctrineAdapter.php.

References getTags().

    {
        return $this->_cache->save(
            $data,
            $this->_prefix . $id,
            $this->getTags(),
            $lifeTime
        );
    }

Here is the call graph for this function:

Robo47_Cache_DoctrineAdapter::_getCacheKeys (  )  [protected]

Fetch an array of all keys stored in cache.

Returns:
array Returns the array of cache keys

Definition at line 223 of file DoctrineAdapter.php.

References getPrefix().

    {
        $ids = $this->_cache->getIds();
        $prefix = $this->getPrefix();
        $length = strlen($prefix);
        foreach($ids as $key => $id) {
            $ids[$key] = substr($id, $length);
        }
        return $ids;
    }

Here is the call graph for this function:

Robo47_Cache_DoctrineAdapter::getCache (  ) 

Get Cache.

Returns:
Zend_Cache_Core

Definition at line 99 of file DoctrineAdapter.php.

    {
        return $this->_cache;
    }

Robo47_Cache_DoctrineAdapter::getPrefix (  ) 

Get Prefix.

Returns:
string

Definition at line 77 of file DoctrineAdapter.php.

Referenced by _getCacheKeys().

    {
        return $this->_prefix;
    }

Here is the caller graph for this function:

Robo47_Cache_DoctrineAdapter::getTags (  ) 

Get Tags.

Returns:
array

Definition at line 121 of file DoctrineAdapter.php.

Referenced by _doSave().

    {
        return $this->_tags;
    }

Here is the caller graph for this function:

Robo47_Cache_DoctrineAdapter::setCache ( cache  ) 

Set Cache.

Parameters:
Zend_Cache_Core|string $cache
Returns:
Robo47_Cache_DoctrineAdapter *Provides Fluent Interface*

Definition at line 148 of file DoctrineAdapter.php.

References _cacheFromRegistry().

Referenced by __construct().

    {
        if (is_string($cache)) {
            $cache = $this->_cacheFromRegistry($cache);
        }
        if (!$cache instanceof Zend_Cache_Core) {
            $message = 'Cache is not instance of Zend_Cache_Core';
            throw new Robo47_Cache_Exception($message);
        }
        $this->_cache = $cache;
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Cache_DoctrineAdapter::setPrefix ( prefix  ) 

Set Prefix.

Parameters:
string $prefix
Returns:
Robo47_Cache_DoctrineAdapter *Provides Fluent Interface*

Definition at line 88 of file DoctrineAdapter.php.

Referenced by __construct().

    {
        $this->_prefix = $prefix;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Cache_DoctrineAdapter::setTags ( array $  tags = array()  ) 

Set Tags.

Parameters:
array $tags
Returns:
Robo47_Cache_DoctrineAdapter *Provides Fluent Interface*

Definition at line 110 of file DoctrineAdapter.php.

Referenced by __construct().

    {
        $this->_tags = $tags;
        return $this;
    }

Here is the caller graph for this function:


Member Data Documentation

Robo47_Cache_DoctrineAdapter::$_cache = null [protected]

Definition at line 46 of file DoctrineAdapter.php.

Robo47_Cache_DoctrineAdapter::$_prefix = '' [protected]

Prefix used with all keys.

Parameters:
string 

Definition at line 52 of file DoctrineAdapter.php.

Robo47_Cache_DoctrineAdapter::$_tags = array() [protected]

Definition at line 58 of file DoctrineAdapter.php.


The documentation for this class was generated from the following file: