File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
packages/cubejs-client-core/src Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import ProgressResult from './ProgressResult';
66import HttpTransport , { ErrorResponse , ITransport , TransportOptions } from './HttpTransport' ;
77import RequestError from './RequestError' ;
88import {
9+ CacheMode ,
910 ExtractTimeMembers ,
1011 LoadResponse ,
1112 MetaResponse ,
@@ -107,6 +108,10 @@ export type CubeSqlOptions = LoadMethodOptions & {
107108 * Query timeout in milliseconds
108109 */
109110 timeout ?: number ;
111+ /**
112+ * Cache mode for query execution
113+ */
114+ cache ?: CacheMode ;
110115} ;
111116
112117export type CubeSqlSchemaColumn = {
@@ -711,6 +716,7 @@ class CubeApi {
711716 ( ) => {
712717 const request = this . request ( 'cubesql' , {
713718 query : sqlQuery ,
719+ cache : options ?. cache ,
714720 method : 'POST' ,
715721 signal : options ?. signal ,
716722 fetchTimeout : options ?. timeout
@@ -768,7 +774,8 @@ class CubeApi {
768774 fetchTimeout : options ?. timeout ,
769775 baseRequestId : uuidv4 ( ) ,
770776 params : {
771- query : sqlQuery
777+ query : sqlQuery ,
778+ cache : options ?. cache
772779 }
773780 } ) ;
774781
Original file line number Diff line number Diff line change @@ -526,3 +526,28 @@ export type ProgressResponse = {
526526 stage : string ;
527527 timeElapsed : number ;
528528} ;
529+
530+ /**
531+ * Cache mode options for query execution.
532+ *
533+ * - **stale-if-slow** (default): Equivalent to previously used `renewQuery: false`.
534+ * If refresh keys are up-to-date, returns the value from cache.
535+ * If refresh keys are expired, tries to return the value from the database.
536+ * Returns fresh value from the database if the query executed until the first "Continue wait" interval is reached.
537+ * Returns stale value from cache otherwise.
538+ *
539+ * - **stale-while-revalidate**: AKA "backgroundRefresh".
540+ * If refresh keys are up-to-date, returns the value from cache.
541+ * If refresh keys are expired, returns stale data from cache.
542+ * Updates the cache in background.
543+ *
544+ * - **must-revalidate**: Equivalent to previously used `renewQuery: true`.
545+ * If refresh keys are up-to-date, returns the value from cache.
546+ * If refresh keys are expired, tries to return the value from the database.
547+ * Returns fresh value from the database even if it takes minutes and many "Continue wait" intervals.
548+ *
549+ * - **no-cache**: AKA "forceRefresh".
550+ * Skips refresh key checks.
551+ * Returns fresh data from the database, even if it takes minutes and many "Continue wait" intervals.
552+ */
553+ export type CacheMode = 'stale-if-slow' | 'stale-while-revalidate' | 'must-revalidate' | 'no-cache' ;
You can’t perform that action at this time.
0 commit comments