gincache

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

README

GinCache Middleware

build workflow PkgGoDev

Overview

Middleware utility for caching requests.

Twitter Follow

Compatibility

This utility is compatible with Go 1.18.

Submitting issues

The Split team monitors all issues submitted to this issue tracker. We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.

Contributing

Please see Contributors Guide to find all you need to submit a Pull Request (PR).

License

Licensed under the Apache License, Version 2.0. See: Apache License.

About Split

Split is the leading Feature Delivery Platform for engineering teams that want to confidently deploy feature flags as fast as they can develop them. Split’s fine-grained management, real-time monitoring, and data-driven experimentation ensure that new feature flags will improve the customer experience without breaking or degrading performance. Companies like Twilio, Salesforce, GoDaddy and WePay trust Split to power their feature delivery.

To learn more about Split, contact hello@split.io, or get started with feature flags for free at Split.

Split has built and maintains SDKs for:

For a comprehensive list of open source projects visit our Github page.

Learn more about Split:

Visit split.io/product for an overview of Split, or visit our documentation at help.split.io for more detailed information.

Documentation

Index

Constants

View Source
const StickyEntry = "c_sticky"

StickyEntry is the name of the context key to be set when we want an entry to be sticky `sticky` entries are not purged when the cache is full. Only when we forcefully evict them

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheFlusher

type CacheFlusher interface {
	EvictAll()
	Evict(key string)
	EvictBySurrogate(surrogate string)
}

CacheFlusher defines the interface to be used by components that need to evict/flush entries from the cache

type KeyFactoryFn

type KeyFactoryFn func(ctx *gin.Context) string

KeyFactoryFn defines the function signature for a Key Factory

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware struct implements a gin middleware that offers request-caching

func New

func New(options *Options) *Middleware

New creates a new middleware with a custom key factory function

func (*Middleware) Evict

func (h *Middleware) Evict(key string)

Evict a single entry

func (*Middleware) EvictAll

func (h *Middleware) EvictAll()

EvictAll clears all the cahed entries

func (*Middleware) EvictBySurrogate

func (h *Middleware) EvictBySurrogate(key string)

EvictBySurrogate keys referenced by a surrogate

func (*Middleware) Handle

func (h *Middleware) Handle(ctx *gin.Context)

Handle is the function that should be passed to your router's `.Use()` method

type Options

type Options struct {
	Size             int
	KeyFactory       KeyFactoryFn
	SurrogateFactory SurrogateFactoryFn
	SuccessfulOnly   bool
}

Options wraps all parameters used to configure the caching middleware

type SurrogateFactoryFn

type SurrogateFactoryFn func(ctx *gin.Context) []string

SurrogateFactoryFn defines the function signature for a Surrogate key list factory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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