You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(api-gateway): Introduce cache mode option for /cubesql API (#9972)
* add cache option to the query
* Pass CacheMode from /cubesql to backend
* imject CacheMode into more places
* update normalizeQuery with cache mode
* pass cache mode within graphql
* pass new cache mode in sqlApiLoad in API GW
* fix types imports
* update preAggs to use cache option instead of renewQuery
* code polish
* comments with types
* fix query type
* set default cacheMode = 'stale-if-slow' in normalize()
* more types and polish
* backbone code for 'stale-if-slow' & 'stale-while-revalidate'
* make query cache aware of queryBody.cache === 'must-revalidate'
* First attempt to implement 'no-cache' scenario
* add cache to open api spec and regenerate rust client
* pass cache mode to cubeScan
* cargo clippy/fmt
* Implement background refresh
* add cache mode descriptions
* remove query cache mode from normalize query
* pass cacheMode to getSqlResponseInternal
* remove obsolete
* add cacheMode as input param in orchestratorApi
* open api spec fix
* fix cubesql after introducing cacheMode
* rename cache → cacheMode
* clean up obsolete
* pass cache_mode from SqlApiLoadPayload
* fix important
* move 'no-cache' variant into queryCache.cachedQueryResult()
* remove cacheMode from client query body types (it's incorrect)
* switch RefreshScheduler to use cacheMode instead of renewQuery
* remove obsolete continueWait flag
* fix refresh scheduler
* add fallback to renewQuery in api gw
* fix tests
* Docs
* Deprecation
* refactor api gw: move copy/paste into this.normalizeCacheMode()
* fix tests snapshots
* return cacheMode into query object
* fix tests
* some cleanup (removed renewQuery)
* update cacheMod in graphql
* return back cache as public prop in query
* fix
* lint fix
# Conflicts:
# packages/cubejs-api-gateway/package.json
* fix subscribe()
* remove cache from subscribe
* fix CacheMode serialization
* refactor: move normalizeQueryCacheMode to normalize
---------
Co-authored-by: Igor Lukanin <[email protected]>
| Deprecated |[`renewQuery` parameter of the `/v1/load` endpoint](#renewquery-parameter-of-the-v1load-endpoint)| v1.3.73 ||
69
70
70
71
### Node.js 8
71
72
@@ -412,3 +413,8 @@ This environment variable was renamed to [`CUBEJS_SCHEDULED_REFRESH_QUERIES_PER_
412
413
413
414
Node.js 20 is in maintenance mode from [November 22, 2024][link-nodejs-eol]. This means
414
415
no more new features, only security updates. Please upgrade to Node.js 22 or higher.
416
+
417
+
### `renewQuery` parameter of the `/v1/load` endpoint
418
+
419
+
This parameter is deprecated and will be removed in future releases. See [cache control](https://cube.dev/docs/product/apis-integrations/rest-api#cache-control)
420
+
options and use the new `cache` parameter of the `/v1/load` endpoint instead.
|`jobs`|[`/v1/pre-aggregations/jobs`][ref-ref-paj]| ❌ No |
@@ -248,9 +248,20 @@ should be unique for each separate request. `spanId` should define user
248
248
interaction span such us `Continue wait` retry cycle and it's value shouldn't
249
249
change during one single interaction.
250
250
251
-
## Troubleshooting
251
+
## Cache control
252
252
253
-
### `Continue wait`
253
+
[`/v1/load`][ref-ref-load] and [`/v1/cubesql`][ref-ref-cubesql] endpoints of the REST API
254
+
allow to control the cache behavior. The following querying strategies with regards to
255
+
the cache are supported:
256
+
257
+
| Strategy | Description |
258
+
| --- | --- |
259
+
|`stale-if-slow`| If [refresh keys][ref-refresh-keys] are up-to-date, returns cached value. If expired, tries to return fresh value from the data source. If the data source query is slow (hits [`Continue wait`](#continue-wait)), returns stale value from cache. |
260
+
|`stale-while-revalidate`| If [refresh keys][ref-refresh-keys] are up-to-date, returns cached value. If expired, returns stale data from cache and updates cache in background. |
261
+
|`must-revalidate`| If [refresh keys][ref-refresh-keys] are up-to-date, returns cached value. If expired, always waits for fresh value from the data source, even if slow (hits one or more [`Continue wait`](#continue-wait) intervals). |
262
+
|`no-cache`| Skips [refresh key][ref-refresh-keys] checks. Always returns fresh data from the data source, regardless of cache or query performance. |
263
+
264
+
## `Continue wait`
254
265
255
266
If the request takes too long to be processed, the REST API responds with
256
267
`{ "error": "Continue wait" }` and the status code 200.
0 commit comments