This module provides local file-based cache functionality for persistent data storage during build operations.
::: tip TIP
To use this module, you need to import it first: import("core.cache.localcache")
:::
::: tip API
localcache.set(cachename: <string>, key: <string>, value: <any>)
:::
| Parameter | Description |
|---|---|
| cachename | Required. Cache name string |
| key | Required. Cache key string |
| value | Required. Cache value (can be any Lua value) |
No return value
import("core.cache.localcache")
-- Store a value with single key
localcache.set("mycache", "key1", {1, 2, 3})
::: tip API
localcache.get(cachename: <string>, key: <string>)
:::
| Parameter | Description |
|---|---|
| cachename | Required. Cache name string |
| key | Required. Cache key string |
| Type | Description |
|---|---|
| any | Returns the cached value if found, nil otherwise |
import("core.cache.localcache")
-- Get a value with single key
local value = localcache.get("mycache", "key1")
::: tip API
localcache.set2(cachename: <string>, key1: <string>, key2: <string>, value: <any>)
:::
| Parameter | Description |
|---|---|
| cachename | Required. Cache name string |
| key1 | Required. First-level cache key string |
| key2 | Required. Second-level cache key string |
| value | Required. Cache value (can be any Lua value) |
No return value
import("core.cache.localcache")
-- Store a value with two-level keys
localcache.set2("mycache", "user", "name", "tboox")
::: tip API
localcache.get2(cachename: <string>, key1: <string>, key2: <string>)
:::
| Parameter | Description |
|---|---|
| cachename | Required. Cache name string |
| key1 | Required. First-level cache key string |
| key2 | Required. Second-level cache key string |
| Type | Description |
|---|---|
| any | Returns the cached value if found, nil otherwise |
import("core.cache.localcache")
-- Get a value with two-level keys
local name = localcache.get2("mycache", "user", "name")
::: tip API
localcache.clear(cachename?: <string>)
:::
| Parameter | Description |
|---|---|
| cachename | Optional. Cache name string. If omitted, clears all caches |
No return value
import("core.cache.localcache")
-- Clear a specific cache
localcache.clear("mycache")
-- Clear all caches
localcache.clear()