cache

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cache manages slio's on-disk channel and user lookup caches. It exists to avoid repeated conversations.list/users.info calls against the 90s deadline; entries older than TTL are treated as a miss, and callers are expected to refresh from the API and write the fresh result back.

Index

Constants

View Source
const TTL = 24 * time.Hour

TTL is how long a cached lookup stays valid before it's treated as a miss and must be refreshed from the API.

Variables

This section is empty.

Functions

func Dir

func Dir(key string) (string, error)

Dir returns the cache directory for a given key, honoring XDG_CACHE_HOME.

Types

type ChannelInfo

type ChannelInfo struct {
	ID   string
	Name string
}

ChannelInfo is a single channel to cache, keyed by name for #name resolution.

type Store

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

Store manages the channel/user caches for one cache key: a profile name, or (when SLIO_TOKEN bypasses profile resolution) a workspace team ID.

func Open

func Open(key string) (*Store, error)

Open returns a Store for the given cache key.

func (*Store) ChannelIDByName

func (s *Store) ChannelIDByName(name string, now time.Time) (id string, ok bool, err error)

ChannelIDByName returns the cached ID for a channel name, and whether the entry was found and still fresh as of now. A false result (miss or stale) means the caller should refresh from the API and call PutChannels.

func (*Store) PutChannels

func (s *Store) PutChannels(channels []ChannelInfo, now time.Time) error

PutChannels replaces the cached channel listing. Channel names/IDs are only ever available as a full list from users.conversations, so a partial merge doesn't apply here.

func (*Store) PutUser

func (s *Store) PutUser(userID, displayName string, now time.Time) error

PutUser upserts a single user's cached display name, leaving other cached users untouched (unlike channels, users are looked up and refreshed one at a time via users.info).

func (*Store) UserDisplayName

func (s *Store) UserDisplayName(userID string, now time.Time) (name string, ok bool, err error)

UserDisplayName returns the cached display name for a user ID, and whether the entry was found and still fresh as of now.

Jump to

Keyboard shortcuts

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