Version: v0.0.0-...-8be75a9 Latest Latest

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

Go to latest
Published: Jan 27, 2020 License: GPL-3.0 Imports: 6 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Cache

type Cache interface {
	Get(key string) (*Item, bool)
	Set(key string, item *Item)
	GarbageCollect(timeToExpire time.Duration)

Cache - basic cache interface

func New

func New(expiration time.Duration) Cache

New - cache factory

type Item

type Item struct {
	// contains filtered or unexported fields

Item - basic cache item representation

func NewItem

func NewItem(recorder *httptest.ResponseRecorder) *Item

NewItem - constructor

func (*Item) Data

func (i *Item) Data() []byte

Data - item's data getter

func (*Item) Header

func (i *Item) Header() http.Header

Header - header data getter

type MapCache

type MapCache struct {
	// contains filtered or unexported fields

MapCache - simplest cache implementation based on map and mutex

func (*MapCache) GarbageCollect

func (c *MapCache) GarbageCollect(timeToExpire time.Duration)

GarbageCollect - each 30 seconds clear stale items, should be started as goroutine

func (*MapCache) Get

func (c *MapCache) Get(uri string) (*Item, bool)

Get - deliver cached item if it exists

func (*MapCache) Set

func (c *MapCache) Set(uri string, item *Item)

Set - set cached item

Source Files

Jump to

Keyboard shortcuts

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