Documentation
¶
Index ¶
- type ClipStore
- func (s *ClipStore) ExpiredClips() (expired []*model.Clip, timerCh <-chan time.Time, kick <-chan struct{})
- func (s *ClipStore) Get(id string) (*model.Clip, bool)
- func (s *ClipStore) ListAll() []*model.Clip
- func (s *ClipStore) Load() error
- func (s *ClipStore) Remove(id string) error
- func (s *ClipStore) Save(clip *model.Clip) error
- func (s *ClipStore) StorePath() string
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 ¶
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) Load ¶
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 ¶
Remove deletes the {id}.json metadata file and the image file (if ImageClip), then removes the clip from the in-memory index.