cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopePublic  = Scope("PUBLIC")
	ScopePrivate = Scope("PRIVATE")
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(h http.Handler) http.Handler

Middleware returns an instance of cachedServer.

func SetHint

func SetHint(ctx context.Context, scope Scope, maxAge time.Duration)

func WithCacheControlExtension

func WithCacheControlExtension(ctx context.Context) context.Context

Types

type CacheControlExtension

type CacheControlExtension struct {
	Version int    `json:"version"`
	Hints   []Hint `json:"hints"`
	// contains filtered or unexported fields
}

func CacheControl

func CacheControl(ctx context.Context) *CacheControlExtension

func (*CacheControlExtension) AddHint

func (cache *CacheControlExtension) AddHint(h Hint)

func (*CacheControlExtension) OverallPolicy

func (cache *CacheControlExtension) OverallPolicy() OverallCachePolicy

OverallPolicy return a calculated cache policy

type Extension

type Extension struct{}

func (Extension) ExtensionName

func (c Extension) ExtensionName() string

func (Extension) InterceptResponse

func (c Extension) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response

func (Extension) Validate

func (c Extension) Validate(_ graphql.ExecutableSchema) error

type Hint

type Hint struct {
	Path   ast.Path `json:"path"`
	MaxAge float64  `json:"maxAge"`
	Scope  Scope    `json:"scope"`
}

type OverallCachePolicy

type OverallCachePolicy struct {
	MaxAge float64
	Scope  Scope
}

func GetOverallCachePolicy

func GetOverallCachePolicy(cache *CacheControlExtension) (OverallCachePolicy, bool)

GetOverallCachePolicy is responsible to extract cache policy from a Response. If does not have any cacheControl in Extensions, it will return (empty, false)

type Scope

type Scope string

Jump to

Keyboard shortcuts

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