cache

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache keeps what was read from GitHub, so the next launch shows it at once and asks only for what changed. All of it can be read again: losing it costs a slower start, nothing more. Drafts are not kept here.

Index

Constants

View Source
const (
	MineFile    = "gists.json"
	StarredFile = "starred.json"
)

The files of the lists, in the cache directory.

Variables

This section is empty.

Functions

func Sort

func Sort(gists []model.Gist)

Sort orders gists by their last update, newest first.

func Viewer

func Viewer(path string) string

Viewer is the account the list in the file at path was read for, or "".

Types

type Contents

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

Contents keeps gists read whole, for showing, one file each in a directory.

func OpenContents

func OpenContents(dir string) *Contents

OpenContents is the contents in dir.

func (*Contents) Clear

func (c *Contents) Clear() error

Clear drops all that is kept.

func (*Contents) Load

func (c *Contents) Load(id string, updated time.Time) (model.Gist, bool)

Load reads the gist as kept, if it is still as of updated, the time the list says it last changed.

func (*Contents) Remove

func (c *Contents) Remove(id string) error

Remove drops what is kept of the gist, which need not be there.

func (*Contents) Save

func (c *Contents) Save(g model.Gist) error

Save keeps g.

type List

type List struct {
	Gists []model.Gist `json:"gists"`
	Pages []Page       `json:"pages,omitempty"`
	Read  time.Time    `json:"read"`
}

List is a list of gists as last read, without their content, newest update first. Only the list of the user's own gists has Pages.

func Merge

func Merge(l List, pages []model.ListPage, read time.Time) List

Merge is the list that pages, just read and in any order, make of the list l. A page that was not modified holds what it held in l.

func (List) ETags

func (l List) ETags() []string

ETags are those of Pages, the first page's first.

type Page

type Page struct {
	IDs  []string `json:"ids"`
	ETag string   `json:"etag"`
}

Page is a page of the list as last read.

type Store

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

Store is one file holding a list for one account on one host.

func Open

func Open(path, host, viewer string) *Store

Open is the store in path for viewer on host.

func (*Store) Load

func (s *Store) Load() (List, bool, error)

Load reads the list. A missing file, or one of another format, host or viewer, gives no list. One that cannot be read gives no list and the error, for the log.

func (*Store) Save

func (s *Store) Save(l List) error

Save replaces the list. The content of a file is left out: it is kept by Contents, and only for as long as it is current.

Jump to

Keyboard shortcuts

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