Help us shape the future of Go! Take the 2026 Go Developer Survey

pgcache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMod

type CacheMod func(*PgCache)

modifier functions for optional fields

func WithTTL

func WithTTL(ttl int) CacheMod

WithTTL sets the TTL (time-to-live) for cache entries in seconds. Default is 86400 seconds (1 day).

type PgCache

type PgCache struct {
	DbPool *sql.DB `required:"true"`
	TTL    int

	CacheTable      string `required:"true"`
	CleanerInterval int    `default:"60"` // in seconds
	// contains filtered or unexported fields
}

func NewPgCache

func NewPgCache(dbPool *sql.DB, cacheTable string, modifiers ...CacheMod) *PgCache

func (*PgCache) CleanUp

func (s *PgCache) CleanUp(ctx context.Context, interval int)

func (*PgCache) ClearCacheStore

func (s *PgCache) ClearCacheStore()

func (*PgCache) CreateCacheTable

func (s *PgCache) CreateCacheTable()

func (*PgCache) Delete

func (s *PgCache) Delete(id string)

func (*PgCache) DeleteExpired

func (s *PgCache) DeleteExpired()

func (*PgCache) DropCacheStore

func (s *PgCache) DropCacheStore()

func (*PgCache) Get

func (s *PgCache) Get(id string) ([]byte, bool)

func (*PgCache) Put

func (s *PgCache) Put(id string, content []byte)

func (*PgCache) PutWitTTL

func (s *PgCache) PutWitTTL(id string, content []byte, ttl int)

func (*PgCache) StartCleaner

func (s *PgCache) StartCleaner(interval int)

func (*PgCache) StopCleaner

func (s *PgCache) StopCleaner()

Jump to

Keyboard shortcuts

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