Cache - Maple Programming Help

Home : Support : Online Help : Programming : Procedures and Functions : Cache Package : Cache/RemoveTemporary

Cache

 RemoveTemporary
 remove a temporary entry from the cache table

 Calling Sequence RemoveTemporary( cache, key )

Parameters

 cache - cache table or procedure: the object the entry is removed from key - list: the key to remove

Description

 • The RemoveTemporary command removes the temporary entry for which key is the key.  The cache table can be given directly as cache, or cache can refer to a procedure that has, or can have, a cache remember table.  If such a procedure is given and it has a cache remember table, the temporary entry is removed from that table.  If the procedure does not have a table no action is taken.
 • To handle an expression sequence as a key, key must be given in a list.  The actual key used for the entry is op(key).
 • To add a temporary entry to a cache table, use AddTemporary.

Examples

 > $\mathrm{c1}≔\mathrm{Cache}\left(\right)$
 ${\mathrm{c1}}{≔}{\mathrm{Cache}}{}\left({512}\right)$ (1)
 > $\mathrm{Cache}:-\mathrm{AddTemporary}\left(\mathrm{c1},\left[x\right],y\right)$
 > $\mathrm{Cache}:-\mathrm{AddTemporary}\left(\mathrm{c1},\left[y\right],z\right)$
 > $\mathrm{eval}\left(\mathrm{c1}\right)$
 ${\mathrm{Cache}}{}\left({512}{,}'{\mathrm{temporary}}'{=}\left[{y}{=}{z}{,}{x}{=}{y}\right]\right)$ (2)
 > $\mathrm{Cache}:-\mathrm{RemoveTemporary}\left(\mathrm{c1},\left[x\right]\right)$
 > $\mathrm{eval}\left(\mathrm{c1}\right)$
 ${\mathrm{Cache}}{}\left({512}{,}'{\mathrm{temporary}}'{=}\left[{y}{=}{z}\right]\right)$ (3)
 > $\mathrm{Cache}:-\mathrm{RemoveTemporary}\left(\mathrm{c1},\left[y\right]\right)$
 > $\mathrm{eval}\left(\mathrm{c1}\right)$
 ${\mathrm{Cache}}{}\left({512}\right)$ (4)
 > p := proc(x,y) option cache; x+y; end proc;
 ${p}{:=}{\mathbf{proc}}\left({x}{,}{y}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{cache}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{+}{y}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)
 > $p\left(1,1\right)$
 ${2}$ (6)
 > $\mathrm{Cache}:-\mathrm{AddTemporary}\left(p,\left[2,2\right],8\right)$
 > $\mathrm{Cache}:-\mathrm{AddTemporary}\left(p,\left[1,2\right],5\right)$
 > $p\left(2,2\right)$
 ${8}$ (7)
 > $\mathrm{Cache}:-\mathrm{RemoveTemporary}\left(p,\left[2,2\right]\right)$
 > $p\left(2,2\right)$
 ${4}$ (8)
 > $\mathrm{op}\left(4,\mathrm{eval}\left(p\right)\right)$
 ${\mathrm{Cache}}{}\left({512}{,}'{\mathrm{temporary}}'{=}\left[\left({1}{,}{2}\right){=}{5}{,}\left({2}{,}{2}\right){=}{4}{,}\left({1}{,}{1}\right){=}{2}\right]\right)$ (9)
 > $p\left(1,2\right)$
 ${5}$ (10)
 > $\mathrm{Cache}:-\mathrm{RemoveTemporary}\left(p,\left[1,2\right]\right)$
 > $p\left(1,2\right)$
 ${3}$ (11)
 > $\mathrm{op}\left(4,\mathrm{eval}\left(p\right)\right)$
 ${\mathrm{Cache}}{}\left({512}{,}'{\mathrm{temporary}}'{=}\left[\left({1}{,}{2}\right){=}{3}{,}\left({2}{,}{2}\right){=}{4}{,}\left({1}{,}{1}\right){=}{2}\right]\right)$ (12)