Sugar_CacheControl

Sugar_CacheControl

The only instance of this class is available as module:natural-lenses/sugar#cache.

Members

(readonly) totalAllocated :number

Current total of allocated cache slots

Source:
Since:
  • 2.3.0
Type:
  • number

(readonly) used :number

Current number of cache slots consumed

Source:
Since:
  • 2.3.0
Type:
  • number

Methods

addCapacity(size) → {Sugar_CacheControl~AllocationAdjuster}

Create an allocation of parser cache entries

Source:
Since:
  • 2.3.0

Cache allocations should be made by any package consuming this package and making significant use of sugar syntax. It can be used to either temporarily boost the cache size or to more permanently boost the cache size for ongoing operations.

Parameters:
Name Type Description
size Number

Number of cache slots to allocate

Returns:

A function to cancel or adjust the allocation

Type
Sugar_CacheControl~AllocationAdjuster

Type Definitions

AllocationAdjuster(newSizeopt)

Source:
Since:
  • 2.3.0

Call this to adjust the size of the allocation (which returned this function); setting newSize to 0 (the default) cancels the allocation, though it can be reinstated by later calls to this function.

Parameters:
Name Type Attributes Default Description
newSize number <optional>
0

The new size (>= 0) for this allocation