Memos
Small caches for paths the game runs many times a frame: one per frame, one timed.
The Explorer searches everything on this page, and the classes of the game too.
WaxMemoModule
Small caches for hot paths: a frame memo forgets everything when the frame changes, a timed one forgets an entry after its seconds. A hook the game calls hundreds of times a frame answers the same question from one of these after the first time.
Below, memo stands for one of these.
memo.frame()
A cache that holds its entries for the rest of the current frame.
memo.frame(): WaxMemoReturns WaxMemo
memo.timed(seconds)
A cache whose entries last this many seconds from when they were set.
memo.timed(seconds: number): WaxTimedMemo| Parameter | Type |
|---|---|
seconds | number |
Returns WaxTimedMemo
WaxMemo
You get one from memo.frame. Below, memo stands for one of these.
| Property | Type | Description |
|---|---|---|
count | integer | How many entries it holds. |
hits | integer | How many times get or take answered from an entry. |
memo:get(key)
The value kept under the key, or nil. Keys are any Lua value; false is kept as a value.
memo:get(key: any): any| Parameter | Type |
|---|---|
key | any |
Returns any
memo:has(key)
True when an entry is there.
memo:has(key: any): boolean| Parameter | Type |
|---|---|
key | any |
Returns boolean
memo:set(key, value)
Keeps a value under the key and answers it.
memo:set(key: any, value: any): any| Parameter | Type |
|---|---|
key | any |
value | any |
Returns any
memo:take(key, fn, ...)
The value kept under the key, or fn(...) kept under it now. A nil answer is not kept.
memo:take(key: any, fn: fun(...): any, ...: any): any| Parameter | Type |
|---|---|
key | any |
fn | fun(...): any |
... | any |
Returns any
memo:clear()
Forgets every entry.
memo:clear()Returns nothing.
WaxTimedMemo
It can also do everything WaxMemo can. You get one from memo.timed. Below, timedMemo stands for one of these.
timedMemo:sweep()
Drops every entry whose seconds are over.
timedMemo:sweep()Returns nothing.