PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TCachePageStatePersister

TCachePageStatePersister class

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 setCacheModuleID CacheModuleID. 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 setCacheTimeout CacheTimeout 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 setCacheTimeout CacheTimeout.

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="System.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="System.Web.UI.TCachePageStatePersister" />
</pages>
TComponent
Extended by TCachePageStatePersister implements IPageStatePersister
Package: System\Web\UI
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.1.1
Located at Web/UI/TCachePageStatePersister.php
Methods summary
public
# getPage( )

Implementation of

IPageStatePersister::getPage()
public
# setPage( TPage $page )

Parameters

$page
TPage
the page that this persister works for.

Implementation of

IPageStatePersister::setPage()
public string
# getCacheModuleID( )

Returns

string
the ID of the cache module.
public
# setCacheModuleID( string $value )

Parameters

$value
string
the ID of the cache module. If not set, the primary cache module will be used.
public ICache
# getCache( )

Returns

ICache
the cache module being used for data storage
public integer
# getCacheTimeout( )

Returns

integer
the number of seconds in which the cached state will expire. Defaults to 1800.
public
# setCacheTimeout( integer $value )

Parameters

$value
integer
the number of seconds in which the cached state will expire. 0 means never expire.

Throws

TInvalidDataValueException
if the number is smaller than 0.
public string
# getKeyPrefix( )

Returns

string
prefix of cache variable name to avoid conflict with other cache data. Defaults to 'statepersister'.
public
# setKeyPrefix( string $value )

Parameters

$value
string
prefix of cache variable name to avoid conflict with other cache data
protected string
# calculateKey( string $timestamp )

Parameters

$timestamp
string
micro timestamp when saving state occurs

Returns

string
a key that is unique per user request
public
# save( mixed $data )

Saves state in cache.

Saves state in cache.

Parameters

$data
mixed
state to be stored

Implementation of

IPageStatePersister::save()
public mixed
# load( )

Loads page state from cache.

Loads page state from cache.

Returns

mixed
the restored state

Throws

THttpException
if page state is corrupted

Implementation of

IPageStatePersister::load()
Methods inherited from TComponent
__call(), __construct(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO