Class wwCache

The wwCache class provides a simple caching mechanisms for strings. Caching allows you to generate output once, store it to the cache and then attempt to retrieve it from the cache if it already exists the next time the same content is required.

Cached items are accessible by key and have an expiration, which allows for timing the availability of cached content to a timeout period that content is valid.

Caching is powerful for storing previously generated output - complete HTML repsonses, or HTML fragments of a page. XML results or fragments of results. You can even cache binary content like the result of a PDF output generation for example. Anything that can be represented as a string can be cached.

Caching can provide huge performance gains for your applications by avoiding regenerating output and not requiring you to go back to the database to re-run complex queries. Instead results are returned from a single indexed key of the cache cursor or table.

Relation
  wwCache

Remarks

The cache is implemented as a cursor, so the contents of the cache is not permanently stored on disk, but stored in temporary files.

Category list items are case sensitive

Class Members

MemberDescription

AddItem

This method adds an item to the cache.

o.AddItem(lcKey as String, lcValue as String, lnTimeoutSeconds as Integer)

Expire

Removes all expired entries from the cache data file.

o.Expire()

GetItem

Retrieves an item by key from the cache. Item is returned if it exists and not expired.

o.GetItem(lcKey as String)

IsCached

Determines whether an item exists in the cache or not.

o.IsCached(lcKey as String)

Open

Opens the cache cursor. Either creates it or just uses it if already open.

o.Open()

Reindex

Packs and reindexes the file specified in the cFixedFileName. This method works only if the cFixedFilename property is set and only if an exclusive lock can be set on the table.

o.Reindex()

Remove

This method removes an entry from the Cache.

o.Remove(lcKey)

cCacheCursor

The name of the cursor used for caching.

cFixedFileName

This property allows you to specify a fixed filename for the cache. including the .DBF extension.

nDefaultCacheTimeout

The default timeout for the cache in seconds.

Requirements

Assembly: wwCache.prg

See also:

How wwCache works | When and How to use Caching

© West Wind Technologies, 1996-2018 • Updated: 03/14/16
Comment or report problem with topic