WebSetCacheLimit Function

Action

This function allows you to implement different cache resizing strategies. You can use this function (usually at the beginning of your script - Init transaction) to enable the emulation of a cache size limit. Without specifying this function the cache size will not be limited. When you specify this function Silk Performer's cache manager will automatically check the cache size on every write operation to the cache. If the size exceeds the size specified by the nMaxSize parameter it deletes cache entries, beginning with the oldest entries, till the cache size drops below nReducedSize or no more documents older (or of equal age) than nSeconds are available.

注: That it never deletes entries which are younger than nSeconds seconds.

Include file

WebApi.bdh

Syntax

WebSetCacheLimit( in nMaxSize     : number,
                  in nReducedSize : number optional,
                  in nSeconds     : number optional );
Parameter Description
nMaxSize Cache limit in bytes.
nReducedSize If the cache manager gets triggered (nMaxSize exceeded) it starts to delete cache entries (beginning with the oldest) which are older (or of equal age) than nSecond seconds, in order to reach a cache size of below nReducedSize bytes (optional). Omit this parameter (or specify 0) to delete all cache entries, which fulfil the age restriction.
nSeconds Specifies the minimum age which a document must have to be able to get cleared by the cache manager (only if the specified nMaxSize is exceeded) (optional). Omit this parameter to disable the age calculation (force the achievement of the specified size).

Example

dcltrans
  transaction TInit
  begin
    WebSetCacheLimit(1000000, 500000, 10 );
  end TInit;

 transaction TWeb
 begin
    WebPageUrl("http://lab3/stadyn_file500k.html");
    print(string(WebCacheGetSize()));
    Wait 3.0;

    WebPageUrl("http://lab3/stadyn_file500k.html?x=1");
    print(string(WebCacheGetSize()));
    Wait 3.0;

    WebPageUrl("http://lab3/stadyn_file500k.html?x=2");
    print(string(WebCacheGetSize()));
    Wait 3.0;

    WebPageUrl("http://lab3/stadyn_file500k.html?x=3");
    print(string(WebCacheGetSize()));
    Wait 3.0;

    WebPageUrl("http://lab3/stadyn_file500k.html?x=4");
    print(string(WebCacheGetSize()));

  end TWeb;

Output

512000
1024000
1536000
1536000
512000