Class CachingDocumentSource
java.lang.Object
org.springframework.graphql.support.CachingDocumentSource
- All Implemented Interfaces:
DocumentSource
Base class for
DocumentSource
implementations providing support for
caching loaded documents.- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionCachingDocumentSource
(DocumentSource delegate) Constructor with theDocumentSource
to actually load documents. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Remove all entries from the document cache.reactor.core.publisher.Mono<String>
getDocument
(String name) Return the document that matches the given name.boolean
Whethercaching
is enabled.void
setCacheEnabled
(boolean cacheEnabled) Enable or disable caching of resolved documents.
-
Constructor Details
-
CachingDocumentSource
Constructor with theDocumentSource
to actually load documents.- Parameters:
delegate
- the delegate document source
-
-
Method Details
-
setCacheEnabled
public void setCacheEnabled(boolean cacheEnabled) Enable or disable caching of resolved documents.By default, set to
true
.- Parameters:
cacheEnabled
- enable iftrue
and disable iffalse
-
isCacheEnabled
public boolean isCacheEnabled()Whethercaching
is enabled. -
getDocument
Description copied from interface:DocumentSource
Return the document that matches the given name.- Specified by:
getDocument
in interfaceDocumentSource
- Parameters:
name
- the name to use for the lookup- Returns:
Mono
that completes either with the document content or with an error, but never empty.
-
clearCache
public void clearCache()Remove all entries from the document cache.
-