var = amtcache('get',package,flags);
amtcache('set',package,variables);
amtcache supports the following commands:
| 'get' | gets the content of a package from the cache. variables = amtcache('get',package) reads a package from the cache and outputs its content in var. package must a be a string identifying the package of variables. If the package contains multiple variables, variables can be a list of variables like [var1, var2, ... , varN] = .... The order of returned variables is the same as that used for saving in cache. ... = amtcache('get',package,flags) allows to control the behaviour of accessing the cache. flags can be:
|
| 'set' | stores variables as a package in the cache. amtcache('set',package, variables) saves variables in the cache using the name package. variables can be a list of variables separated by comma. |
| 'getURL' | outputs the URL of the cache in the internet. |
| 'setURL' | sets the URL of the internet cache to a new URL. |
| 'clearAll' | clears the cache directory. An interactive confirmation is required. |
This is an example of using the cache in a function. In this example, we store the variables x, y, and z in the package xyz:
definput.import={'amtcache'};
[flags,~] = ltfatarghelper({},definput,varargin);
[x,y,z] = amtcache('get', 'xyz', flags.cachemode);
if isempty(x)
% calculate your variables x,y,z here
amtcache('set','xyz',x,y,z);
end
% use your variables x,y,z here
Note that in this example, the flags indicating the mode of caching are stored in flags.cachemode which can be achieved by:
definput.import={'amtcache'};
[flags,keyvals] = ltfatarghelper({},definput,varargin);
at the begin of the function. This way, the cache mode can be provided by the user if required.