Class ExternalSourceCacheService
java.lang.Object
org.elasticsearch.xpack.esql.datasources.cache.ExternalSourceCacheService
- All Implemented Interfaces:
Closeable,AutoCloseable
Coordinator-only, in-memory cache service for external source metadata.
Maintains two independent caches:
- Schema cache (20% of budget, 5m TTL) — shared across users
- Listing cache (80% of budget, 30s TTL) — isolated by credential hash
setExpireAfterWrite for the initial implementation.
Lazy TTL with ETag revalidation is deferred to a follow-up PR.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()voidclose()getOrComputeListing(ListingCacheKey key, CacheLoader<ListingCacheKey, FileList> loader) Returns a cached file listing or stores the provided one.Returns a cached schema entry or computes it via the loader.booleanvoidsetEnabled(boolean enabled)
-
Constructor Details
-
ExternalSourceCacheService
-
-
Method Details
-
getOrComputeSchema
public SchemaCacheEntry getOrComputeSchema(SchemaCacheKey key, CacheLoader<SchemaCacheKey, SchemaCacheEntry> loader) throws ExceptionReturns a cached schema entry or computes it via the loader. The loader is only invoked on a cache miss. When the cache is disabled, the loader is called directly (bypassing the cache).- Throws:
Exception
-
getOrComputeListing
public FileList getOrComputeListing(ListingCacheKey key, CacheLoader<ListingCacheKey, FileList> loader) throws ExceptionReturns a cached file listing or stores the provided one. The loader is only invoked on a cache miss. When the cache is disabled, the loader is called directly (bypassing the cache).- Throws:
Exception
-
setEnabled
public void setEnabled(boolean enabled) -
isEnabled
public boolean isEnabled() -
clearAll
public void clearAll() -
usageStats
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-