Builder.php

Show: inherited
Table of Contents

\Conjoon_Builder

Package: Conjoon\Builder

This class can be used to implement a concrete strategy for returning objects out of the cache or directly from the data storage.

Providing a cache object when instantiating an object of this class, the get() method should return the object either directly out of the cache or from the data storage. Later look ups should use the cache, wheras the logic to determine whether the cache is still valid is done by the cache object itself.

Example for a concrete implementation of get():


 class User_Builder extends Conjoon_Builder {

 public function get($id)
 {
     $user = null;

     if (!$this->_cache->test($id)) {

         $user = new User;
         // expensive operations here

         $this->_cache->save($user, $id);
     } else {
         $user = $this->_cache->load($id);
     }

     return $user;

 }

}

Children
\Conjoon_Modules_Service_Twitter_Account_Builder
\Conjoon_Modules_Groupware_Email_Message_Builder
\Conjoon_Modules_Groupware_Email_Account_Builder
\Conjoon_Modules_Groupware_Email_Folder_FolderRootTypeBuilder
\Conjoon_Modules_Groupware_Feeds_Account_Builder
\Conjoon_Modules_Groupware_Feeds_Account_ListBuilder
\Conjoon_Modules_Groupware_Feeds_Item_Builder
\Conjoon_Modules_Groupware_Feeds_Item_ListBuilder
Author
Thorsten-Suckow-Homberg  
Category
Conjoon  

Properties

Propertyprotectedstring  $_buildClass= 'null'

mandatory, the class the builder has to use for creating cached objects
Default valuenullDetails
Type
string
Propertyprotected\Zend_Cache_Core  $_cache= 'null'

Default valuenullDetails
Type
\Zend_Cache_Core
Propertyprotected\Conjoon_BeanContext_Decoratable  $_model= 'null'

Default valuenullDetails
Type
\Conjoon_BeanContext_Decoratable
Propertyprotectedbool  $_noBuildClassNeeded= 'false'

Explicitely set this to true if you do not need a build class required before cache gets resolved
Default valuefalseDetails
Type
bool
Propertyprotectedarray  $_validGetOptions= 'array()'

Default valuearray()Details
Type
array
Propertyprotectedarray  $_validTagOptions= 'array()'

Default valuearray()Details
Type
array

Methods

methodpublic__construct( \Zend_Cache_Core $cache = null,  $model = null ) : void

Constructor.

Parameters
Name Type Description
$cache \Zend_Cache_Core

The cache to use for retrieving or storing an object. If not supplied, this builder won't have any caching functionality.

$model

Conjoon_BeanContext_Decoratable

methodprotected_build( array $options, \, $model ) : mixed
abstract

An abstract function which concrete implementation has to be provided in the classes deriving from Conjoon_Builder.

It's purpose is to build the objects that have to be cached.

Parameters
Name Type Description
$options array
$model \,

Conjoon_BeanContext_Decoratable $model

Returns
Type Description
mixed
methodprotected_buildId( Array $options ) : String
abstract

An abstract function which returns an id that can be used to identify cache objects.

Parameters
Name Type Description
$options Array

a hash with key/value pairs which can be used to build an id

Returns
Type Description
String
methodprotected_checkValidGetOptions(  $options ) : void

Validates the keys of the passed array against the whitelist of keys specified in $_validGetOptions.

Throws an exception if there is a key missing in the passed argument that was specified in $_validGetOptions.

Parameters
Name Type Description
$options
methodprotected_checkValidTagOptions(  $options ) : void

Validates the keys of the passed array against the whitelist of keys specified in $_validTagOptions.

Throws an exception if there is a key missing in the passed argument that was specified in $_validTagOptions.

Parameters
Name Type Description
$options
methodprotected_getModel( ) : \Conjoon_BeanContext_Decoratable
abstract

Returns
Type Description
\Conjoon_BeanContext_Decoratable
methodprotected_getTagList( Array $options ) : Array

An abstract function which returns a numerical array with tag ids as their values.

IF this method does not return an empty array, those ids will be used to tag a cached item.

Parameters
Name Type Description
$options Array

a hash with key/value pairs which can be used to build a tag list

Returns
Type Description
Array
methodpublicbuildId( array $options ) : String

A function which returns an id under which an object in the cache can be identified.

The returned key will be used to identify objects in the clean() and get() method of this class.

Parameters
Name Type Description
$options array

An associative array of options to use. If the _validGetOptions property is specified, the options will be checked against this property.

Returns
Type Description
String
methodpublicclean( string $type, array $options = array() ) : void

Cleans the cache based on the passed parameters.

Parameters
Name Type Description
$type string

Any of Zend_Cache::CLEANING_MODE_ALL Zend_Cache::CLEANING_MODE_OLD Zend_Cache::CLEANING_MODE_MATCHING_TAG Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG

$options array

When using any tag related clean up, this array should hold all related tags for this operation

Details
See
\Zend_Cache::clean  
methodpubliccleanCacheForTags(  $options ) : void

Cleans the cache with all cached items that where tagged with the tags found in the return value of getTagList.

Parameters
Name Type Description
$options
Details
See
\clean  
See
\getTagList  
methodpublicget( array $options ) : mixed

Checks whether the keys specified in $_validGetOptions are available in $options. Throws an exception if that is not the case, otherwise calls the concrete implementation of _get.

Parameters
Name Type Description
$options array
Returns
Type Description
mixed
Throws
Exception Description
\Conjoon_Builder_Exception if the keys specified in $_validGetOptions are not specified in $options
Details
See
\_get  
methodprotectedgetTagList( array $options ) : Array

A function which returns an array with tag ids that can be used to tag a cached item.

Parameters
Name Type Description
$options array

An associative array of options to use. If the _validTagOptions property is specified, the options will be checked against this property.

Returns
Type Description
Array
methodpublicremove( array $options ) : void

Removes an object from the cache, if available.

Parameters
Name Type Description
$options array

An array of options which will be considered in buildId

Documentation was generated by DocBlox 0.18.1.