Godot 4 · GDScript · Downloadable content
get_cached_content
Reads the locally cached copy of a content item, with no network call.
Signature
get_cached_content(key: String) -> VariantWhat it does
Returns the last value persisted to the on-device content cache (user://gamdato_content_<key>.json); purely local, no request is sent. The cache is populated ONLY by the sync flows, sync_always_download() and sync_content_keys(); a plain get_game_content() or get_bootstrap() does NOT write it. It survives across sessions for offline use. Cached values keep the server envelope shape, so your uploaded value lives at data[key].
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| key | String | required | The content key whose locally cached copy you want to read. |
How to call it
Read it any time after the content has been synced at least once. Ideal for an optimistic read: show the cached copy instantly, then refresh via a sync when content_loaded fires.
Returns: Variant: the cached content for key (Dictionary, Array, or primitive), or null if nothing is cached for that key yet.
Example
var cached: Variant = Gamdato.get_cached_content("levels")
if cached != null:
_load_levels(cached["levels"]) # show cached data instantly (value at data[key])
Gamdato.sync_always_download() # refresh in the backgroundUse cases
- Display downloaded content immediately on startup without waiting for the network.
- Serve content while offline from the on-device cache.