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
- func Dir(key string) (string, error)
- type ChannelInfo
- type Store
- func (s *Store) ChannelIDByName(name string, now time.Time) (id string, ok bool, err error)
- func (s *Store) PutChannels(channels []ChannelInfo, now time.Time) error
- func (s *Store) PutUser(userID, displayName string, now time.Time) error
- func (s *Store) UserDisplayName(userID string, now time.Time) (name string, ok bool, err error)
Constants ¶
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 ¶
Types ¶
type ChannelInfo ¶
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 (*Store) ChannelIDByName ¶
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.