store

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClipStore

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

ClipStore manages clip persistence on disk and an in-memory index for fast queries.

func NewClipStore

func NewClipStore(storePath string) *ClipStore

NewClipStore creates a ClipStore rooted at the given directory.

func (*ClipStore) ExpiredClips

func (s *ClipStore) ExpiredClips() (expired []*model.Clip, timerCh <-chan time.Time, kick <-chan struct{})

ExpiredClips returns all clips whose ExpiresAt is before the current time. It resets the internal timer to fire when the next clip expires. Returns: expired clips, timer channel (nil if no clips remain), kick channel that is closed when a new clip becomes the earliest to expire.

func (*ClipStore) Get

func (s *ClipStore) Get(id string) (*model.Clip, bool)

Get returns a clip by ID from the in-memory index.

func (*ClipStore) ListAll

func (s *ClipStore) ListAll() []*model.Clip

ListAll returns all clips from the in-memory byCreated list.

func (*ClipStore) Load

func (s *ClipStore) Load() error

Load scans storePath for *.json metadata files and populates the in-memory index. Invalid files are cleaned up with a warning log. Expired clips are removed on startup.

func (*ClipStore) Remove

func (s *ClipStore) Remove(id string) error

Remove deletes the {id}.json metadata file and the image file (if ImageClip), then removes the clip from the in-memory index.

func (*ClipStore) Save

func (s *ClipStore) Save(clip *model.Clip) error

Save persists clip metadata as {id}.json and inserts it into the in-memory index maintaining descending CreatedAt order.

func (*ClipStore) StorePath

func (s *ClipStore) StorePath() string

StorePath returns the base storage directory.

Jump to

Keyboard shortcuts

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