cache

package
Version: v0.0.0-...-ba60edf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2020 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package cache implements caching of GraphQL requests by allowing resolvers to provide hints about their cacheability, which can be used by the transport handlers (e.g. HTTP) to provide caching indicators in the response.

Index

Constants

View Source
const (
	ScopePublic scope = iota
	ScopePrivate
)

Cache control scopes.

Variables

This section is empty.

Functions

func AddHint

func AddHint(ctx context.Context, hint Hint)

AddHint applies a caching hint to the request context.

func Hintable

func Hintable(ctx context.Context) (hintCtx context.Context, hint <-chan Hint, done func())

Hintable extends the context with the ability to add cache hints.

func TTL

func TTL(d time.Duration) *time.Duration

TTL defines the cache duration.

Types

type Hint

type Hint struct {
	MaxAge *time.Duration
	Scope  scope
}

Hint defines a hint as to how long something should be cached for.

func (Hint) String

func (h Hint) String() string

String resolves the HTTP Cache-Control value of the Hint.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL