Get string data from the server's internal memory cache by key.

 

Syntax

function MemCacheGet(const AKey: string): string;

 

Parameters and return values

Parameter

Type

Value

AKey

string

record key, a unique text string.

 

Function result

The string stored by the specified key. If the entry does not exist, the function returns an empty string. If the key exists, the original record will be removed from the cache.


If it's important to distinguish between a missing entry and an empty value, use MemCacheExists before reading.

 

Example

var
  sValue: string;
begin
  if MemCacheExists('server_status') then begin
    sValue := MemCacheGet('server_status');
    mLogScript('Cached status: ' + sValue, 'MEMCACHE');
  end
  else
    mLogScript('Key not found in cache', 'MEMCACHE');
end.



Script work time

[20:45:37] (Log "MemCacheGetExample"): [MEMCACHE] Key not found in cache

[20:45:37] (Run "MemCacheGetExample"): Script operation time: 2 ms

[20:45:37] (Run "MemCacheGetExample"): Script done successfully.

 

See also

MemCacheExists

mLogScript