Overview of the Cache Package - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Procedures and Functions : Cache Package : CachePackage

Overview of the Cache Package


Calling Sequence


List of Cache Package Commands

Calling Sequence





The Cache package exports functions for manipulating cache tables, both as option cache remember tables and as top-level objects.


The top-level Cache command creates a new cache table.


Cache tables are similar to normal tables: they associate a key with a value. However, a cache table stores two kinds of entries, permanent and temporary. Permanent entries are similar to normal remember table entries.  Once added to a table they remain in the table until explicitly removed.  A temporary entry may be removed when another entry is inserted  because a cache table has a fixed maximum number of temporary elements it can store. Therefore inserting a temporary entry into a cache table may cause another temporary entry to be removed from the table.


Cache tables are primarily intended for use as remember tables.  A caching remember table allows a procedure to permanently store return values while allowing dynamically remembered values to be collected by the system.  Cache tables also have special garbage collection rules.  A check is performed whenever memory is allocated from the system.  If the total amount of memory allocated exceeds the current value of the cacheclearlimit option to kernelopts, all cache tables are automatically cleared of all temporary elements on the next garbage collection.


Because cache tables have two types of entries, it is possible for a single table to have two entries using the same key, one temporary and one permanent. In these cases, the temporary entry is always used.


The option cache can be specified in a procedure.  This option is similar to option remember except that a cache remember table is created instead of a standard remember table.  A cache remember table can also be created by using the Cache command. The entries that are automatically added  to the remember table of a procedure with option cache are temporary.  To create permanent entries, the Cache[AddPermanent] command can be used.  The option cache is incompatible with options remember and system.  An error is raised if they are used together.  For more information on using option cache see option cache.


Each command in the Cache package can be accessed by using either the long form or the short form of the command name in the command calling sequence.


As the underlying implementation of the Cache package is a module, it is also possible to use the form Cache:-command to access a command from the package. For more information, see Module Members.

List of Cache Package Commands


The following is a list of available commands.














Note: There is also a top-level Cache command that creates a new cache table.


To display the help page for a particular Cache command, see Getting Help with a Command in a Package.

See Also

Cache Command