Public Member Functions | Public Attributes

Robo47_Cache_Backend_Array Class Reference

List of all members.

Public Member Functions

 clean ($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array())
 Clean some cache records.
 getCapabilities ()
 Return an associative array of capabilities (booleans) of the backend.
 getFillingPercentage ()
 Return the filling percentage of the backend storage.
 getIds ()
 Return an array of stored cache ids.
 getIdsMatchingAnyTags ($tags=array())
 Return an array of stored cache ids which match any given tags.
 getIdsMatchingTags ($tags=array())
 Return an array of stored cache ids which match given tags.
 getIdsNotMatchingTags ($tags=array())
 Return an array of stored cache ids which don't match given tags.
 getMetadatas ($id)
 Return an array of metadatas for the given cache id.
 getTags ()
 Return an array of stored tags.
 load ($id, $doNotTestCacheValidity=false)
 Test if a cache is available for the given id and (if yes) return it (false else).
 remove ($id)
 Remove a cache record.
 save ($data, $id, $tags=array(), $specificLifetime=false)
 Save some string datas into a cache record.
 test ($id)
 Test if a cache is available or not (for the given id).
 touch ($id, $extraLifetime)
 Give (if possible) an extra lifetime to the given cache id.

Public Attributes

 $data = array()

Detailed Description

Definition at line 34 of file Array.php.


Member Function Documentation

Robo47_Cache_Backend_Array::clean ( mode = Zend_Cache::CLEANING_MODE_ALL,
tags = array() 
)

Clean some cache records.

Parameters:
string $mode Clean mode
array $tags Array of tags
Returns:
boolean true if no problem

Definition at line 126 of file Array.php.

    {
        switch ($mode) {
            case Zend_Cache::CLEANING_MODE_ALL:
                $this->data = array();
                break;
            case Zend_Cache::CLEANING_MODE_OLD:
            case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
            case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
            case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
                $message = 'Mode ' . $mode . ' not supported';
                throw new Robo47_Cache_Backend_Exception($message);
                break;
            default:
                $message = 'Unknown mode ' . $mode;
                throw new Robo47_Cache_Backend_Exception($message);
                break;
        }
        return true;
    }

Robo47_Cache_Backend_Array::getCapabilities (  ) 

Return an associative array of capabilities (booleans) of the backend.

The array must include these keys :

  • automatic_cleaning (is automating cleaning necessary)
  • tags (are tags supported)
  • expired_read (is it possible to read expired cache records (for doNotTestCacheValidity option for example))
  • priority does the backend deal with priority when saving
  • infinite_lifetime (is infinite lifetime can work with this backend)
  • get_list (is it possible to get the list of cache ids)
Returns:
array associative of with capabilities

Definition at line 259 of file Array.php.

    {
        return array(
            'automatic_cleaning' => false,
            'tags' => false,
            'expired_read' => false,
            'priority' => false,
            'infinite_lifetime' => false,
            'get_list' => false
        );
    }

Robo47_Cache_Backend_Array::getFillingPercentage (  ) 

Return the filling percentage of the backend storage.

Returns:
int integer between 0 and 100

Definition at line 212 of file Array.php.

    {
        return 0;
    }

Robo47_Cache_Backend_Array::getIds (  ) 

Return an array of stored cache ids.

Returns:
array array of stored cache ids (string)

Definition at line 153 of file Array.php.

    {
        return array_keys($this->data);
    }

Robo47_Cache_Backend_Array::getIdsMatchingAnyTags ( tags = array()  ) 

Return an array of stored cache ids which match any given tags.

In case of multiple tags, a logical AND is made between tags

Parameters:
array $tags array of tags
Returns:
array array of any matching cache ids (string)

Definition at line 202 of file Array.php.

    {
        return array();
    }

Robo47_Cache_Backend_Array::getIdsMatchingTags ( tags = array()  ) 

Return an array of stored cache ids which match given tags.

In case of multiple tags, a logical AND is made between tags

Parameters:
array $tags array of tags
Returns:
array array of matching cache ids (string)

Definition at line 176 of file Array.php.

    {
        return array();
    }

Robo47_Cache_Backend_Array::getIdsNotMatchingTags ( tags = array()  ) 

Return an array of stored cache ids which don't match given tags.

In case of multiple tags, a logical OR is made between tags

Parameters:
array $tags array of tags
Returns:
array array of not matching cache ids (string)

Definition at line 189 of file Array.php.

    {
        return array();
    }

Robo47_Cache_Backend_Array::getMetadatas ( id  ) 

Return an array of metadatas for the given cache id.

The array must include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time
Parameters:
string $id cache id
Returns:
array array of metadatas (false if the cache id is not found)

Definition at line 228 of file Array.php.

    {
        return false;
    }

Robo47_Cache_Backend_Array::getTags (  ) 

Return an array of stored tags.

Returns:
array array of stored tags (string)

Definition at line 163 of file Array.php.

    {
        return array();
    }

Robo47_Cache_Backend_Array::load ( id,
doNotTestCacheValidity = false 
)

Test if a cache is available for the given id and (if yes) return it (false else).

Note : return value is always "string" (unserialization is done by the core not by the backend)

Parameters:
string $id Cache id
boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
Returns:
string|false cached datas

Definition at line 57 of file Array.php.

    {
        if (isset($this->data[$id])) {
            return $this->data[$id];
        } else {
            return false;
        }
    }

Robo47_Cache_Backend_Array::remove ( id  ) 

Remove a cache record.

Parameters:
string $id Cache id
Returns:
boolean True if no problem

Definition at line 109 of file Array.php.

    {
        if (isset($this->data[$id])) {
            unset($this->data[$id]);
            return true;
        } else {
            return false;
        }
    }

Robo47_Cache_Backend_Array::save ( data,
id,
tags = array(),
specificLifetime = false 
)

Save some string datas into a cache record.

Note : $data is always "string" (serialization is done by the core not by the backend)

Parameters:
string $data Datas to cache
string $id Cache id
array $tags Array of strings, the cache record will be tagged by each string entry
int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
Returns:
boolean true if no problem

Definition at line 97 of file Array.php.

References $data.

    {
        $this->data[$id] = $data;
        return true;
    }

Robo47_Cache_Backend_Array::test ( id  ) 

Test if a cache is available or not (for the given 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 73 of file Array.php.

    {
        if (isset($this->data[$id])) {
            return true;
        } else {
            return false;
        }
    }

Robo47_Cache_Backend_Array::touch ( id,
extraLifetime 
)

Give (if possible) an extra lifetime to the given cache id.

Parameters:
string $id cache id
int $extraLifetime
Returns:
boolean true if ok

Definition at line 240 of file Array.php.

    {
        return false;
    }


Member Data Documentation

Robo47_Cache_Backend_Array::$data = array()

Definition at line 43 of file Array.php.

Referenced by save().


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