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");constmission=N.cache.get("currentMission");mp.gui.chat.push(`🧩 Current mission: ${mission}`);
✅ Output:
[N.cache] set "currentMission" = "bank_heist"🧩Currentmission:bank_heistд
⚙️ Functions
🧩 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);
Parameter
Type
Default
Description
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.
Parameter
Type
Default
Description
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
Scenario
Example
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 (Map object).
Supports any JSON-serializable value (string, number, object, array).
Server communication handled through NurRage:cache:clientSet and NurRage: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.