N.cache (Client) β Local + Synced Data Storage
N.cache on the client side allows you to store, access, and sync small pieces of data
between the client and server β such as player state, UI variables, or custom values.
Itβs the lightweight βmemoryβ of NurJS that automatically synchronizes with the server when needed.
πΉ Basic Example
N.cache.set("currentMission", "bank_heist");
const mission = N.cache.get("currentMission");
mp.gui.chat.push(`π§© Current mission: ${mission}`);β Output:
[N.cache] set "currentMission" = "bank_heist"
π§© Current mission: bank_heistΠ΄βοΈ Functions
π§© N.cache.set(key, value, sync = true)
N.cache.set(key, value, sync = true)Stores a value in local cache.
If sync = true, it also sends it to the server (NurRage:cache:clientSet).
N.cache.set("weather", "RAIN", true);key
string
β
Unique cache key name
value
any
β
Value to store (string, number, object, etc.)
sync
boolean
true
Whether to sync with the server
β Automatically logs to chat:
π§© N.cache.get(key, def = null)
Retrieves a value from cache, or returns a default if missing.
key
string
β
Key to retrieve
def
any
null
Default value if not found
π§© Server β Client Sync
Whenever the server updates cache values, the client automatically receives updates via:
β You can add listeners or handle it in your UI:
π§ Internal Example
π§© Example β Syncing Player State
πΉ Client
πΉ Server
β Client instantly updates local cache.
π‘ Use Cases
UI State
N.cache.set("hudVisible", true)
Mission Progress
N.cache.set("missionStep", 3)
Player Variables
N.cache.set("seatbelt", true)
Server Sync
Auto-updates values like time, weather, health
βοΈ Internal Notes
Local data is stored in
N.cache._data(Mapobject).Supports any JSON-serializable value (string, number, object, array).
Server communication handled through
NurRage:cache:clientSetandNurRage:cache:update.Logging is automatic (for debug builds).
N.cache (client) is a lightweight and synchronized key-value store.
It helps you quickly store and sync small pieces of state between client and server β
ideal for UIs, missions, HUDs, and player data.
Last updated