cache

package
v0.4.16 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a simple in-memory TTL cache with prefix-based invalidation.

func New

func New(ttl time.Duration) *Cache

New creates a new Cache with the given TTL for entries.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all entries.

func (*Cache) Get

func (c *Cache) Get(key string) (any, bool)

Get returns the cached value for key if it exists and has not expired. Expired entries are lazily deleted.

func (*Cache) Invalidate

func (c *Cache) Invalidate(prefixes ...string)

Invalidate removes all entries whose keys start with any of the given prefixes.

func (*Cache) Set

func (c *Cache) Set(key string, value any)

Set stores a value with the cache's default TTL.

type CachedSearchService

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

CachedSearchService wraps a zendesk.SearchService with a TTL cache. It shares a Cache instance with CachedTicketService so ticket mutations also invalidate search results.

func NewCachedSearchService

func NewCachedSearchService(delegate zendesk.SearchService, c *Cache) *CachedSearchService

NewCachedSearchService creates a caching decorator around the given SearchService.

func (*CachedSearchService) Search

type CachedTicketService

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

CachedTicketService wraps a zendesk.TicketService with a TTL cache. Read operations check the cache first; mutations pass through and invalidate.

func NewCachedTicketService

func NewCachedTicketService(delegate zendesk.TicketService, c *Cache) *CachedTicketService

NewCachedTicketService creates a caching decorator around the given TicketService. The provided Cache instance should be shared with CachedSearchService so that ticket mutations also invalidate search results.

func (*CachedTicketService) Create

func (*CachedTicketService) Delete

func (s *CachedTicketService) Delete(ctx context.Context, id int64) error

func (*CachedTicketService) Get

func (*CachedTicketService) List

func (*CachedTicketService) ListAudits

func (s *CachedTicketService) ListAudits(ctx context.Context, ticketID int64, opts *types.ListAuditsOptions) (*types.AuditPage, error)

func (*CachedTicketService) ListComments

func (s *CachedTicketService) ListComments(ctx context.Context, ticketID int64, opts *types.ListCommentsOptions) (*types.CommentPage, error)

func (*CachedTicketService) Update

Jump to

Keyboard shortcuts

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