Skip to content

Commit

Permalink
docs(readme) clarify use-case for optional 'callback' in get()
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Jan 31, 2024
1 parent 85e71c7 commit ab418e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -445,6 +445,10 @@ in the cache **and** no callback is provided, `get()` will return `nil, nil,
with return values such as `nil, nil, 1`, where 1 signifies a **negative cached
item** found in L1 (cached `nil`).

Not providing a `callback` function allows implementing cache lookup patterns
that are guaranteed to be on-cpu for a more constant, smoother latency tail end
(e.g. with values refreshed in background timers via `set()`).

```lua
local value, err, hit_lvl = cache:get("key")
if value == nil then
Expand Down

0 comments on commit ab418e4

Please sign in to comment.