import { type IAnalyticalBackend } from "@gooddata/sdk-backend-spi"; /** * Cache control can be used to interact with the caching layer - at the moment to reset the contents of the * different top-level caches. * * @public */ export type CacheControl = { /** * Resets all execution caches. * * NOTE: this only resets the top-level caches. If your code holds onto execution results returned by * caching backend, those have additional sub-caches which _will not_ be impacted by this call. */ resetExecutions: () => void; /** * Resets all catalog caches. */ resetCatalogs: () => void; /** * Resets all organization security settings caches. */ resetSecuritySettings: () => void; /** * Resets all workspace attribute caches. */ resetAttributes: () => void; /** * Resets all workspace facts caches. */ resetFacts: () => void; /** * Resets all workspace dataset caches. */ resetDatasets: () => void; /** * Resets all workspace settings caches. */ resetWorkspaceSettings: () => void; /** * Resets the cached geo style. */ resetGeoStyles: () => void; /** * Resets the export templates cache. */ resetExportTemplates: () => void; /** * Resets all workspace insight caches. */ resetInsights: () => void; /** * Resets all workspace measures caches. */ resetMeasures: () => void; /** * Resets all workspace automation caches. */ resetAutomations: () => void; /** * Convenience method to reset all caches (calls all the particular resets). */ resetAll: () => void; }; /** * Specifies where should the caching decorator apply and to what size should caches grow. * * @public */ export type CachingConfiguration = { /** * Maximum number of executions which will have their results cached. The execution fingerprint is used * as cache key - the caching is thus subject to some limitations. See `defFingerprint` function for more * information. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * executions cache is dangerous in applications with long-lived sessions that can create many unique executions - * memory usage will only go up. * * When non-positive number is specified, then no caching will be done. * * Note: When specified, this takes precedence over `maxExecutionsAge`. */ maxExecutions?: number; /** * Maximum age of cached execution results. The value is in milliseconds. * * Items are not pro-actively pruned out as they age, but if you try to get an item that is too old, * it'll drop it and make a new request to the backend. The purpose of the cache setting is not mainly * to limit its size to prevent memory usage grow but to ensure that cached execution results are * refreshed periodically to reflect any data changes on the backend. * * Only used when `maxExecutions` is not specified. * * When non-positive number is specified, then no caching will be done. */ maxExecutionsAge?: number; /** * Maximum number of execution result's pages to cache PER result. The window offset and limit are used as cache key. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * result window cache is dangerous in applications that read result windows in 'random' fashion. * * When non-positive number is specified, then no caching of result windows will be done. * * Note: this option has no effect if execution caching is disabled. */ maxResultWindows?: number; /** * Maximum number of cached geo collection items per execution result. * * @remarks * This limits how many unique combinations of collection filters and attribute values can be stored when * caching responses from {@link @gooddata/sdk-backend-spi#IDataView.readCollectionItems}. Once the number of * cached entries grows beyond this size, least recently used entries will be evicted. * * When non-positive number is specified, caching of collection items will be disabled. */ maxGeoCollectionItemsPerResult?: number; /** * Maximum number of workspaces for which to cache catalogs. The workspace identifier is used as cache key. For * each workspace, there will be a cache entry holding `maxCatalogOptions` entries. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * catalogs cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching of result windows will be done. */ maxCatalogs?: number; /** * Catalog can be viewed in many different ways - determined by the options specified during load. This option * indicates how many unique options to cache results for. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. How dangerous * this is depends on how many catalog load options combinations your application allows to create. Recommended * approach is to load entire catalog of all items once and reuse it. If there is chance that your app can create * many unique options, then it is better to bound this. * * Setting non-positive number here is invalid. If you want to turn off catalog caching, tweak the `maxCatalogs`. */ maxCatalogOptions?: number; /** * Specify function to call once the caching is set up. If present, the function will be called * with an instance of {@link CacheControl} which you can use to interact with the caches. * * @param cacheControl - cache control instance */ onCacheReady?: (cacheControl: CacheControl) => void; /** * Maximum number of organizations that will have its security settings cached. The scope string built by * particular backend implementation from organization ID will be used as cache key. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * security settings organization cache is dangerous in applications with long-lived sessions that can * create many unique requests and memory usage will only go up. * * When non-positive number is specified, then no caching will be done. */ maxSecuritySettingsOrgs?: number; /** * Maximum number of URLs per organization that will have its validation result cached. The URL * and validation context is used to form a cache key. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * security settings organization URL cache is dangerous in applications with long-lived sessions that can * create many unique requests and memory usage will only go up. * * Setting non-positive number here is invalid. If you want to turn off organization security settings caching, * tweak the `maxSecuritySettingsOrgs`. */ maxSecuritySettingsOrgUrls?: number; /** * Maximum age of cached organization's URL validation results. The value is in milliseconds. * * Items are not pro-actively pruned out as they age, but if you try to get an item that is too old, * it'll drop it and make a new request to the backend. The purpose of the cache setting is not mainly * to limit its size to prevent memory usage grow (tweak `maxSecuritySettingsOrgUrls` for that) * but to propagate URL whitelist changes on backend to the long-lived application sessions. * * Setting non-positive number here is invalid. If you want to turn off organization security settings * caching, tweak the `maxSecuritySettingsOrgs`. */ maxSecuritySettingsOrgUrlsAge?: number; /** * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceAttributesService} calls. * The workspace identifier is used as cache key. * For each workspace, there will be a cache entry holding `maxAttributeDisplayFormsPerWorkspace` entries for attribute display form-related calls. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching will be done. */ maxAttributeWorkspaces?: number; /** * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceAutomationsService} calls. * The workspace identifier is used as cache key. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching will be done. */ maxAutomationsWorkspaces?: number; /** * Maximum number of insights to cache per workspace. * * Only the read-only, idempotent {@link @gooddata/sdk-backend-spi#IWorkspaceInsightsService.getInsight} * call is cached. The insight reference (plus any options that change the response) is used as cache key. * This mainly serves to de-duplicate in-flight requests so that concurrent dashboard widgets referencing * the same insight share a single network request. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. * * When non-positive number is specified, then no caching of insights will be done. */ maxInsightsPerWorkspace?: number; /** * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceFactsService} calls. * The workspace identifier is used as cache key. * For each workspace, there will be a cache entry holding `maxFactsPerWorkspace` entries for fact-related calls. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching will be done. */ maxFactsWorkspaces?: number; /** * Maximum number of facts to cache per workspace. * * This limit applies independently to the cache of facts (`getFact`) and the cache of fact dataset * metadata (`getFactDatasetMeta`). * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * facts cache may be OK in applications where number of facts is small and/or they are requested * infrequently - the cache will be limited naturally and will not grow uncontrollably. * * Setting non-positive number here is invalid. If you want to turn off facts caching, * tweak the `maxFactsWorkspaces` value. */ maxFactsPerWorkspace?: number; /** * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceMeasuresService} calls. * The workspace identifier is used as cache key. * For each workspace, there will be a cache entry holding `maxMeasuresPerWorkspace` entries. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching will be done. */ maxMeasuresWorkspaces?: number; /** * Maximum number of measures to cache per workspace. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * measures cache may be OK in applications where number of measures is small and/or they are requested * infrequently - the cache will be limited naturally and will not grow uncontrollably. * * Setting non-positive number here is invalid. If you want to turn off measures caching, * tweak the `maxMeasuresWorkspaces` value. */ maxMeasuresPerWorkspace?: number; /** * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceDatasetsService} calls. * The workspace identifier is used as cache key. * For each workspace, there will be a cache entry holding `maxDatasetsPerWorkspace` entries for dataset metadata reads. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * cache may be OK in applications where number of workspaces is small - the cache will be limited * naturally and will not grow uncontrollably. * * When non-positive number is specified, then no caching will be done. */ maxDatasetWorkspaces?: number; /** * Maximum number of datasets to cache per workspace. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * dataset cache may be OK in applications where number of datasets is small and/or they are requested * infrequently - the cache will be limited naturally and will not grow uncontrollably. * * Setting non-positive number here is invalid. If you want to turn off dataset caching, * tweak the `maxDatasetWorkspaces` value. */ maxDatasetsPerWorkspace?: number; /** * Maximum number of organizations for which to cache organization-level export templates. * Organization export templates are organization-level, so typically a single entry suffices. * * When non-positive number is specified, then no caching will be done. */ maxExportTemplatesOrgs?: number; /** * Maximum number of workspaces for which to cache workspace-level export templates. * * When limit is reached, cache entries will be evicted using LRU policy. * * When non-positive number is specified, then no caching will be done. * * For backward compatibility this value is also used as a fallback for * {@link CachingConfiguration.maxExportTemplatesOrgs} when the latter is unset — it used to be * the deprecated alias that sized the organization export-templates cache. */ maxExportTemplatesWorkspaces?: number; /** * Maximum number of attribute display forms to cache per workspace. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * attribute display form cache may be OK in applications where number of attribute display forms is small * and/or they are requested infrequently - the cache will be limited naturally and will not grow uncontrollably. * * Setting non-positive number here is invalid. If you want to turn off attribute display form * caching, tweak the `maxAttributeWorkspaces` value. */ maxAttributeDisplayFormsPerWorkspace?: number; /** * Maximum number of attributes to cache per workspace. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * attribute cache may be OK in applications where number of attributes is small and/or they are requested * infrequently - the cache will be limited naturally and will not grow uncontrollably. * * Setting non-positive number here is invalid. If you want to turn off attribute caching, * tweak the `maxAttributeWorkspaces` value. */ maxAttributesPerWorkspace?: number; /** * Maximum number of common attribute results to cache per workspace. * * This bounds the cache used by `getCommonAttributes` and `getCommonAttributesBatch`, keyed by the * (order-independent) set of input attribute references. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. * * Setting non-positive number here is invalid. If you want to turn off common attribute caching, * tweak the `maxAttributeWorkspaces` value. */ maxCommonAttributesPerWorkspace?: number; /** * Maximum number of connected attribute results to cache per workspace. * * This bounds the cache used by `getConnectedAttributesByDisplayForm`, keyed by the display form * reference identifier/uri. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. * * Setting non-positive number here is invalid. If you want to turn off connected attribute caching, * tweak the `maxAttributeWorkspaces` value. */ maxConnectedAttributesPerWorkspace?: number; /** * Maximum number of attribute element results to cache per workspace. * * Note that not all the queries are cached (e.g. queries with `filter` value). * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * attribute elements cache may be OK in applications where number of attributes and/or their elements is small * and/or they are requested infrequently - the cache will be limited naturally and will not grow uncontrollably. * * The `maxAttributeWorkspaces` value must be positive, otherwise this setting is ignored. * When non-positive number is specified, then no caching of attribute element results will be done. */ maxAttributeElementResultsPerWorkspace?: number; /** * Maximum number of elements in an element list that may be searched locally. * * A query with a `filter` normally always goes to the backend. When the elements of the same attribute * were already loaded in full and there are no more than this many of them, the filter is instead applied * to that list in memory, which spares the backend a request per keystroke. Clearing the filter is * answered from the same list. Above this many elements the query goes to the backend as before. * * The number of lists kept is bounded by `maxAttributeElementResultsPerWorkspace`, and local filtering is * only done when that cache is enabled too. * * When no maximum number is specified, or the specified number is non-positive, then no local filtering * will be done. */ maxAttributeElementsForLocalFiltering?: number; /** * Maximum number of settings for a workspace and for a user to cache per workspace. * * When limit is reached, cache entries will be evicted using LRU policy. * * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded * workspace settings cache is dangerous in applications that change query the settings of many different * workspaces - this will cache quite large objects for each workspace and can make the memory usage go up. * * When non-positive number is specified, then no caching of result windows will be done. */ maxWorkspaceSettings?: number; /** * When true, cache geo assets returned by `backend.geo()`. * * The geo style is the same for all workspaces within a single backend instance. Cached style * entries are keyed by the requested style ID and kept in a small LRU cache. * The default sprite icon list is cached as a single shared promise. This is useful to avoid * repeated network calls when multiple geo charts are rendered on the same page. * * @remarks * Default is false. Set to true to enable caching. */ cacheGeoStyles?: boolean; }; /** * These are the recommended settings for the backend caching. * * @remarks * For more information on what the options mean see {@link CachingConfiguration}. * * @public */ export declare const RecommendedCachingConfiguration: CachingConfiguration; /** * Adds caching layer on top of an existing analytical backend instance. It is currently possible to cache * results of executions and the workspace LDM catalog. * * @remarks see {@link CachingConfiguration} properties for more information. * @param realBackend - real backend to decorate with caching * @param config - caching configuration. {@link RecommendedCachingConfiguration} can be used * @public */ export declare function withCaching(realBackend: IAnalyticalBackend, config: CachingConfiguration): IAnalyticalBackend; //# sourceMappingURL=index.d.ts.map