cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cache stores fetched mail locally so Postline can render a mailbox before the network responds. It is strictly an accelerator: deleting the database costs nothing but a refetch.

Index

Constants

View Source
const DirEnv = "POSTLINE_CACHE_DIR"

DirEnv relocates the cache. Tests set it so a run cannot write fixture mail into the cache of whoever is running them.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath is where cached mail lives.

func Remove

func Remove() error

Remove deletes the cache from disk, along with the journal files SQLite leaves beside it.

Types

type Store

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

Store is a local cache. Every method tolerates a nil receiver, so callers can treat an unavailable cache as a no-op rather than branching everywhere.

func Default

func Default() (*Store, error)

Default opens the cache at the platform's user data location.

func Open

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

Open creates or opens a cache at path.

func (*Store) Clear

func (s *Store) Clear(account string) error

Clear removes everything cached for an account.

func (*Store) Close

func (s *Store) Close() error

Close releases the database.

func (*Store) Labels

func (s *Store) Labels(account string) []mail.Label

Labels returns cached mailboxes, or nil when nothing is cached.

func (*Store) Messages

func (s *Store) Messages(account, threadID string) []mail.Message

Messages returns a cached conversation, or nil when nothing is cached.

func (*Store) SaveLabels

func (s *Store) SaveLabels(account string, labels []mail.Label) error

SaveLabels caches the mailbox list.

func (*Store) SaveMessages

func (s *Store) SaveMessages(account, threadID string, msgs []mail.Message) error

SaveMessages caches a conversation.

func (*Store) SaveThreads

func (s *Store) SaveThreads(account, labelID string, threads []mail.Thread) error

SaveThreads caches the first page of a mailbox.

func (*Store) Threads

func (s *Store) Threads(account, labelID string) []mail.Thread

Threads returns a cached mailbox page, or nil when nothing is cached.

Jump to

Keyboard shortcuts

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