• Publicity: Public Only All

acs-cache-procs.tcl

This file defines the following Objects and Classes: ::acs::HashKeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::PartitionedCache[i], ::acs::LockfreeCache[i], ::acs::Cache[i], ::acs::per_request_cache[i], ::acs::per_thread_cache[i], ::xo::xotcl_package_cache[i], ::xo::xotcl_object_cache[i], ::acs::site_nodes_cache[i], ::acs::site_nodes_children_cache[i], ::xowiki::cache[i], ::acs::permission_cache[i], ::xo::xotcl_object_type_cache[i], ::acs::group_cache[i], ::acs::misc_cache[i], ::acs::site_nodes_id_cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::HashKeyPartitionedCache[i], ::acs::HashKeyPartitionedCache[i], ::acs::HashKeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::HashKeyPartitionedCache[i], ::acs::HashKeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::Cache[i], ::acs::HashKeyPartitionedCache[i], ::acs::HashKeyPartitionedCache[i], ::acs::HashKeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::LockfreeCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::KeyPartitionedCache[i], ::acs::Cache[i], ::acs::LockfreeCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i], ::acs::PartitionedCache[i]

Location:
packages/acs-tcl/tcl/acs-cache-procs.tcl

Procedures in this file

Detailed information

Class ::acs::Cache (public)

 ::nx::Class ::acs::Cache[i]

Base class for cache management

Testcases:
No testcase defined.

Class ::acs::HashKeyPartitionedCache (public)

 ::nx::Class ::acs::HashKeyPartitionedCache[i]

Partitioned cache, where the partition numbers are computed via a hash function. Key-partitioning is based on a modulo function using a special partition_key, which has to be numeric

Testcases:
No testcase defined.

Class ::acs::KeyPartitionedCache (public)

 ::nx::Class ::acs::KeyPartitionedCache[i]

Partitioned cache, where the partition numbers are computed via a modulo function from the numeric keys.

Testcases:
No testcase defined.

Class ::acs::LockfreeCache (public)

 ::nx::Class ::acs::LockfreeCache[i]

Lockfree caches are provided either as per-thread caches or per-request caches, sharing the property that accessing these values does not require locks. Typical applications of these caches are the per_request_cache and per_thread_cache.

See Also:

Testcases:
No testcase defined.

Class ::acs::PartitionedCache (public)

 ::nx::Class ::acs::PartitionedCache[i]

Partitioned cache infrastructure. Partition numbers are computed via a modulo function from the numeric keys.

Testcases:
No testcase defined.

Object ::acs::per_request_cache (public)

 ::acs::LockfreeCache ::acs::per_request_cache[i]

Lockfree cache with per-request live time of the entries. The purpose of the per-request cache is to cache computation results of a single request. The entries of this cache are therefore very short-lived. Some values are needed multiple times per request, and/or they should show consistently the same value during the same request, no matter, if concurrently, a value is changed (e.g. permissions). The per-request cache uses a Tcl variable in the global Tcl namespace, such it will be automatically reclaimed after the request. The per-request cache uses the prefix "::__acs_cache".

Testcases:
No testcase defined.

Object ::acs::per_thread_cache (public)

 ::acs::LockfreeCache ::acs::per_thread_cache[i]

Lockfree cache with per-thread live time of the entries. The per-thread caches use namespaced variables, which are not touched by the automatic per-request cleanup routines of the server. So, the values cached in one requests can be used by some later request in the same thread. The entries are kept in per-thread caches as long as the thread lives, there is so far no automatic mechanism to flush these. So, per-thread caches are typically used for values fetched from the database, which do not change, unless the server is restarted. Note: the usage of per-thread caches is only recommended for static values, which do no change during the life time of the server, since there is so far no automatic measure in place to the flush values in every thread.

Testcases:
No testcase defined.

Object ::xowiki::cache (public)

 ::acs::KeyPartitionedCache ::xowiki::cache[i]

Xowiki cache. This partitioned cache is used for various caching purposes for xowiki. It is used for example for caching includlets (when requested), or for full file names of xowiki::File objects. In case of bottlenecks, increase the number of partitions and the cache size.

Testcases:
No testcase defined.

acs::Cache method flush (public)

 <instance of acs::Cache[i]> flush [ -partition_key partition_key ] \
    key

Flush a single entry in the cache

Switches:
-partition_key (optional)
Parameters:
key (required)

Testcases:
No testcase defined.

acs::Cache method flush_all (public)

 <instance of acs::Cache[i]> flush_all

Flush all contents of all (partitioned) caches. In the case of a base ::acs::Cache, it is identical to "flush_cash".

Testcases:
No testcase defined.

acs::Cache method flush_cache (public)

 <instance of acs::Cache[i]> flush_cache \
    [ -partition_key partition_key ]

Flush all entries in a cache.

Switches:
-partition_key (optional)

Testcases:
No testcase defined.

acs::Cache method flush_pattern (public)

 <instance of acs::Cache[i]> flush_pattern \
    [ -partition_key partition_key ] pattern

Flush in the cache a value based on a pattern operation. Use this function rarely, since on large caches (e.g. 100k entries or more) the glob operation will cause long locks, which should be avoided. The partitioned variants can help to reduce the lock times.

Switches:
-partition_key (optional)
Parameters:
pattern (required)

Testcases:
No testcase defined.

acs::Cache method get (public)

 <instance of acs::Cache[i]> get [ -partition_key partition_key ] \
    key

The "get" method retrieves data from the cache. It should not be used for new applications due to likely race conditions, but legacy applications use this. As implementation, we use the AOLserver API emulation.

Switches:
-partition_key (optional)
Parameters:
key (required)

Testcases:
No testcase defined.

acs::Cache method init (public)

 <instance of acs::Cache[i]> init

If the name was not provided, use the object name as default.

Testcases:
No testcase defined.

acs::Cache method set (public)

 <instance of acs::Cache[i]> set [ -partition_key partition_key ] \
    key value

Set a single value in the cache. This code uses ns_cache_eval to achieve this behavior, which is typically an AOLserver idiom and should be avoided.

Switches:
-partition_key (optional)
Parameters:
key (required)
value (required)

Testcases:
No testcase defined.

acs::Cache method show_all (public)

 <instance of acs::Cache[i]> show_all

Log all cache keys to the system log. The primary usage is for debugging.

Testcases:
No testcase defined.

acs::HashKeyPartitionedCache method flush_pattern (public)

 <instance of acs::HashKeyPartitionedCache[i]> flush_pattern \
    -partition_key partition_key  pattern

flush just in all partitions

Switches:
-partition_key (required)
Parameters:
pattern (required)

Testcases:
No testcase defined.

acs::HashKeyPartitionedCache method set (public)

 <instance of acs::HashKeyPartitionedCache[i]> set \
    -partition_key partition_key  key value

Set a single value in the cache. It transforms the partition key into a hash value. This code uses ns_cache_eval to achieve this behavior, which is typically an AOLserver idiom and should be avoided.

Switches:
-partition_key (required)
Parameters:
key (required)
value (required)

Testcases:
No testcase defined.

acs::KeyPartitionedCache method flush_pattern (public)

 <instance of acs::KeyPartitionedCache[i]> flush_pattern \
    -partition_key partition_key  pattern

Flush just in the determined partition

Switches:
-partition_key (required, integer)
Parameters:
pattern (required)

Testcases:
No testcase defined.

acs::KeyPartitionedCache method set (public)

 <instance of acs::KeyPartitionedCache[i]> set \
    -partition_key partition_key  key value

Set a single value in the cache. This code uses ns_cache_eval to achieve this behavior, which is typically an AOLserver idiom and should be avoided.

Switches:
-partition_key (required, integer)
Parameters:
key (required)
value (required)

Testcases:
No testcase defined.

acs::LockfreeCache method eval (public)

 <instance of acs::LockfreeCache[i]> eval -key key  \
    [ -no_cache no_cache ] [ -no_empty ] \
    [ -from_cache_indicator from_cache_indicator ] cmd

Use the "prefix" to determine whether the cache is per-thread or per-request.

Switches:
-key (required)
key for caching, should start with package-key and a dot to avoid name clashes
-no_cache (optional)
list of returned values that should not be cached
-no_empty (optional, defaults to "false")
don't cache empty values. This flag is deprecated, one should use the no_cache flag instead.
-from_cache_indicator (optional)
variable name to indicate whether the returned value was from cache or not
Parameters:
cmd (required)
command to be executed.
Returns:
return the last value set (don't use "return").

Testcases:
No testcase defined.

acs::LockfreeCache method flush (public)

 <instance of acs::LockfreeCache[i]> flush [ -pattern pattern ]

Flush a cache entry based on the pattern (which might be wild-card-free). Currently, the clusterwide flushing is omitted. We have the per-request cache (clusterwide operations do not make sense for this) and per-thread caching. The per-thread caching application have to be aware that flushing is happening only in one thread, so clusterwide operations will only start to make sense, when the all threads of a server would be cleaned.

Switches:
-pattern (optional, defaults to "*")

Testcases:
No testcase defined.

acs::LockfreeCache method get (public)

 <instance of acs::LockfreeCache[i]> get -key key  var

Get entry with the provided key from this cache if it exists. In most cases, the "eval" method should be used.

Switches:
-key (required)
cache key
Parameters:
var (required)
Returns:
return boolean value indicating success.

Testcases:
No testcase defined.

acs::PartitionedCache method flush_all (public)

 <instance of acs::PartitionedCache[i]> flush_all \
    [ -partition_key partition_key ]

Flush all entries in all partitions of a cache.

Switches:
-partition_key (optional)

Testcases:
No testcase defined.

acs::PartitionedCache method init (public)

 <instance of acs::PartitionedCache[i]> init

If the name was not provided, use the object name as default for the cache name.

Testcases:
No testcase defined.

acs::PartitionedCache method show_all (public)

 <instance of acs::PartitionedCache[i]> show_all

Log all cache keys of all partitions to the system log. The primary usage is for debugging.

Testcases:
No testcase defined.

acs::disk_cache_eval (public)

 acs::disk_cache_eval -call call -key key -id id

Evaluate an expression. When the acs-tcl.DiskCache parameter is set, cache the result on the disk. If a cache already exists, return the cached value.

Switches:
-call (required)
a Tcl snippet executed in the caller scope.
-key (required)
a key used to name the directory where the disk cache will be stored.
-id (required)
an id used to name the file where the disk cache will be stored. The name will also depend on a hash of the actual snippet.

Partial Call Graph (max 5 caller/called nodes):
%3 test_disk_cache disk_cache (test acs-tcl) acs::disk_cache_eval acs::disk_cache_eval test_disk_cache->acs::disk_cache_eval ad_file ad_file (public) acs::disk_cache_eval->ad_file ad_tmpdir ad_tmpdir (public) acs::disk_cache_eval->ad_tmpdir parameter::get_from_package_key parameter::get_from_package_key (public) acs::disk_cache_eval->parameter::get_from_package_key template::util::read_file template::util::read_file (public) acs::disk_cache_eval->template::util::read_file template::util::write_file template::util::write_file (public) acs::disk_cache_eval->template::util::write_file

Testcases:
disk_cache

acs::disk_cache_flush (public)

 acs::disk_cache_flush -key key -id id

Flushes the filesystem cache.

Switches:
-key (required)
the key used to name the directory where the disk cache is stored.
-id (required)
the id used to name the file where the disk cache is stored.
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 test_disk_cache disk_cache (test acs-tcl) acs::disk_cache_flush acs::disk_cache_flush test_disk_cache->acs::disk_cache_flush ad_tmpdir ad_tmpdir (public) acs::disk_cache_flush->ad_tmpdir

Testcases:
disk_cache
[ show source ]