System
[ class tree: System ] [ index: System ] [ all elements ]

Class: TCacheManager

Source Location: /TCacheManager.php

Class Overview


TCacheManager class

Class Details

[line 35]
TCacheManager class

TCacheManager manages the caching of components. The creation of a PRADO component may be time consuming because it needs to read many files to finish the definition of a component. TCacheManager provides a way to accelerate this process by saving a serialized copy in memory and in file. An instantiation of the same typed component can then be directly unserialized from the copy which significantly shortens the time needed for creation.




version:  v1.0, last update on 2004/08/13 21:44:52
author:  Qiang Xue <qiang.xue@gmail.com>


[ Top ]

Variables

Constants

Methods



Class Variables

$components = array()

[line 65]

list of components cached so far



access:  protected

Type:   array


[ Top ]

$currentModule = ''

[line 60]

current module name



access:  protected

Type:   string


[ Top ]

$enabled =

[line 45]

if the caching is enabled.



access:  protected

Type:   boolean


[ Top ]

$rootPath =

[line 50]

the root cache path.



access:  protected

Type:   string


[ Top ]

$savePath =

[line 55]

the current cache save path



access:  protected

Type:   string


[ Top ]



Class Methods


constructor __construct [line 73]

TCacheManager __construct( mixed $config)

Constructor.

Reads the configuration given in the app spec. In particular, the attribute 'enabled' and 'path' are read.




Parameters:

mixed   $config   the configuration.

[ Top ]

method cacheComponent [line 159]

void cacheComponent( TComponent $component)

Saves a component to cache.

This method saves the serialized component into memory and as a file (if necessary).

Derived classes may override this method to provide other ways of caching component. Be sure to override cloneComponent to make it consistent.




access:  public
see:  TCacheManager::cloneComponent()


Parameters:

TComponent   $component   the component to be cached

[ Top ]

method cloneComponent [line 119]

TComponent cloneComponent( string $type)

Creates a component from cache.

This method unserializes a component from memory or a file.

Derived classes may override this method to provide other ways of caching component. Be sure to override cacheComponent to make it consistent.




return:  the component created, null if failed.
access:  public
see:  TCacheManager::cacheComponent()


Parameters:

string   $type   the type of the component to be created

[ Top ]

method setCurrentModule [line 97]

void setCurrentModule( string $name)

Sets the current module name.

Since module is related with namespace partition, it is important for cache manager to know under which module (namespace) a component is created and cached. Module name affects the location a component is cached.




access:  public


Parameters:

string   $name   the module name

[ Top ]


Class Constants

EXT_CACHE = '.bin'

[line 40]

name extension to cache files (for storing serialized components)


[ Top ]



© 2004-2005 PRADO Software Group. All Rights Reserved.