package cache

import "golang.org/x/pkgsite/internal/cache"

Package cache implements a redis-based page cache for pkgsite.

Index

Types

type Cache

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

Cache is a Redis-based cache.

func New

func New(client *redis.Client) *Cache

New creates a new Cache using the given Redis client.

func (*Cache) Clear

func (c *Cache) Clear(ctx context.Context) (err error)

Clear deletes all entries from the cache.

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, keys ...string) (err error)

Delete deletes the given keys. It does not return an error if a key does not exist.

func (*Cache) DeletePrefix

func (c *Cache) DeletePrefix(ctx context.Context, prefix string) (err error)

DeletePrefix deletes all keys beginning with prefix.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (value []byte, err error)

Get returns the value for key, or nil if the key does not exist.

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, key string, data []byte, ttl time.Duration) (err error)

Put inserts the key with the given data and time-to-live.

Source Files

cache.go

Version
v0.0.0-20250218150137-224a1368cf02 (latest)
Published
Feb 18, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
2 months ago

Tools for package owners.