add a temporary entry to the cache table - Maple Help

Online Help

All Products    Maple    MapleSim


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

Cache[AddTemporary] - add a temporary entry to the cache table

Calling Sequence

AddTemporary( cache, key, value )

Parameters

cache

-

cache table or procedure: the object in which to insert the entry

key

-

list: the key to add

value

-

anything: the value to associate with key

Description

• 

The AddTemporary command creates a temporary entry associating key with value in a cache table.  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 inserted into that table. Otherwise, a new cache table is created, installed as cache's remember table and the temporary entry is inserted into that table.

• 

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).

• 

If more than one argument is passed after key, then an expression sequence containing those arguments is used as value.

• 

Assigning directly into a cache table, using the cache[key] := value notation, creates a temporary entry.  As well, a function with option cache creates a temporary entry when the function is called. Calling AddPermanent is the only way to create a permanent entry into a cache table.

• 

To remove a temporary entry from a cache table use RemoveTemporary.

• 

Creating a temporary entry for a key that already has a permanent entry is not an error.  In this case, the temporary entry is used.

• 

For more information on cache tables, see Cache Package.

Examples

c1:=Cache

c1:=Cache512

(1)

c1a:=b

c1a:=b

(2)

Cache:-AddTemporaryc1,x,y

Cache:-AddTemporaryc1,y,z

evalc1

Cache512,'temporary'=a=b,y=z,x=y

(3)

p := proc(x,y) option cache; x+y; end proc;

p:=procx,yoptioncache;x+yend proc

(4)

p1,1

2

(5)

Cache:-AddTemporaryp,2,2,8

Cache:-AddTemporaryp,1,2,5

p2,2

8

(6)

p1,2

5

(7)

Cache:-AddPermanentp,3,3,5,6,7

p2,2

8

(8)

op4,evalp

Cache512,'temporary'=2,2=8,1,2=5,1,1=2,'permanent'=3,3=5,6,7

(9)

See Also

Cache Package, Cache[AddPermanent], Cache[PermanentEntries], Cache[PermanentIndices], Cache[RemovePermanent], Cache[RemoveTemporary]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam