Class \Prado\Web\UI\TCachePageStatePersister
TCachePageStatePersister implements a page state persistent method based on cache. Page state are stored in cache (e.g. memcache, DB cache, etc.), and only a small token is passed to the client side to identify the state. This greatly reduces the size of the page state that needs to be transmitted between the server and the client. Of course, this is at the cost of using server side resource.
A cache module has to be loaded in order to use TCachePageStatePersister. By default, TCachePageStatePersister will use the primary cache module. A non-primary cache module can be used by setting \Prado\Web\UI\setCacheModuleID. Any cache module, as long as it implements the interface ICache, may be used. For example, one can use TDbCache, TMemCache, TAPCCache, etc.
TCachePageStatePersister uses \Prado\Web\UI\setCacheTimeout to limit the data that stores in cache.
Since server resource is often limited, be cautious if you plan to use TCachePageStatePersister for high-traffic Web pages. You may consider using a small \Prado\Web\UI\setCacheTimeout.
There are a couple of ways to use TCachePageStatePersister. One can override the page's TPage::getStatePersister() method and create a TCachePageStatePersister instance there. Or one can configure the pages to use TCachePageStatePersister in page configurations as follows,
<pages StatePersisterClass="Prado\Web\UI\TCachePageStatePersister"
StatePersister.CacheModuleID="mycache"
StatePersister.CacheTimeout="3600" />
Note in the above, we use StatePersister.CacheModuleID to configure the cache module ID for the TCachePageStatePersister instance.
The above configuration will affect the pages under the directory containing this configuration and all its subdirectories. To configure individual pages to use TCachePageStatePersister, use
<pages>
<page id="PageID" StatePersisterClass="Prado\Web\UI\TCachePageStatePersister" />
</pages>
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Since: 3.1.1
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |