CacheCache
Writing applications that make good use of the cache
Home > Books > Architect's Guide to NetKernel > Implementation > Cache

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


URIs are cache keys

NetKernel will cache the results of a URI SOURCE request to improve system performance. Since the cache uses the URI as the key to look up the cached resource, it is important to use the same URI each time a specific resource is needed.

If arguments used to compute a resource are passed by value, then the result will not be cached. For example, when a computed value is placed into a variable in DPML and passed to another DPML script the result of the DPML script cannot be cached. Equally if a query is passed in from the HTTP transport and gets converted into a XML parameter by the HTTPBridge then this result will be transient.

When creating services for which caching is required the service and the service's clients should be carefully designed to explicitly pass all argument data explicitly in the request URI. A way to achieve this is to convert a resource that must be passed with the request into a data: URI which can effectively be passed by reference. The requestWithArgs accessor creates and issues requests for an active URI and can be a useful way to combine data URIs onto a URI request.

What is cached?

All primary resources such as module resources and files are cacheable including transrepted aspects generated from these resources.

Nearly all accessors in NetKernel Standard Edition mark their responses as intermediate which is a hint to the cache that the resource is transient and should not be cached. This was done to bias the cache to capture the higher level runtime results. DPML and XRL do not declare their results as intermediate and so their results are cacheable.

Dependency Caching

All generated resources retain a record of the resources which were used in the computation of a resource. If any dependent resource is invalidated (either explicitly in a process or in the case of files, externally by editing) then computed resource will be invalidated and cleaned from the cache.

Cache tuning accessors

The following accessors can be used to override default behaviour:
accessor description
attachDependency Used to attach additional explicit dependencies onto the metadata of a resource.
attachGoldenThread A mechanism for controlling validity of resources from certain types of system integration accessors. Works well with relational databases.
expire Set an explicit relative or absolute expiry time on a resource.
declareIntermediate Forces a representation to be marked as intermediate- i.e. don't cache it but allows dependants to be cached.

Tools

The currently cached resources, their URIs and metadata can be inspected by using the Cache Summary view.

© 2003-2007, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.