Class CachingDocumentSource

java.lang.Object
org.springframework.graphql.support.CachingDocumentSource
All Implemented Interfaces:
DocumentSource

public class CachingDocumentSource extends Object implements DocumentSource
Base class for DocumentSource implementations providing support for caching loaded documents.
Since:
1.0.0
Author:
Rossen Stoyanchev
  • Constructor Details

    • CachingDocumentSource

      public CachingDocumentSource(DocumentSource delegate)
      Constructor with the DocumentSource 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 if true and disable if false
    • isCacheEnabled

      public boolean isCacheEnabled()
      Whether caching is enabled.
    • getDocument

      public reactor.core.publisher.Mono<String> getDocument(String name)
      Description copied from interface: DocumentSource
      Return the document that matches the given name.
      Specified by:
      getDocument in interface DocumentSource
      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.