persist

package
v1.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Overview

Package persist provides a persistence layer for the in-memory cache

Package persist provides a bootstrap for the in-memory cache

Package persist provides a persistence layer for the in-memory cache

Package persist provides a bootstrap for the in-memory cache

Package persist provides a persistence layer for the in-memory cache

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxSaveAge is the oldest allowable entry to persist
	MaxSaveAge = 30 * 24 * time.Hour
	// MaxLoadAge is the oldest allowable entry to load
	MaxLoadAge = 45 * 24 * time.Hour
)

Functions

func DefaultDiskPath

func DefaultDiskPath(configPath string, override string) string

Types

type Cacher

type Cacher interface {
	String() string

	Set(string, *Thing) error
	DeleteOlderThan(string, time.Time) error
	GetNewerThan(string, time.Time) *Thing

	Initialize() error
	Save() error
}

Cacher is the cache interface we support

func FromEnv

func FromEnv(backend string, path string, configPath string, reposOverride string) (Cacher, error)

FromEnv is shared magic between binaries

func New

func New(cfg Config) (Cacher, error)

func NewCloudSQL

func NewCloudSQL(cfg Config) (Cacher, error)

NewCloudSQL returns a new Google Cloud SQL store (MySQL)

type Config

type Config struct {
	Type string
	Path string
}

Config is cache configuration

type Disk

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

func NewDisk

func NewDisk(cfg Config) (*Disk, error)

NewDisk returns a new disk cache

func (*Disk) DeleteOlderThan

func (d *Disk) DeleteOlderThan(key string, t time.Time) error

DeleteOlderThan deletes a thing older than a timestamp

func (*Disk) GetNewerThan

func (d *Disk) GetNewerThan(key string, t time.Time) *Thing

GetNewerThan returns a thing older than a timestamp

func (*Disk) Initialize

func (d *Disk) Initialize() error

func (*Disk) Save

func (d *Disk) Save() error

func (*Disk) Set

func (d *Disk) Set(key string, t *Thing) error

Set stores a thing into memory

func (*Disk) String

func (d *Disk) String() string

type Memory

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

func NewMemory

func NewMemory(cfg Config) (*Memory, error)

NewMemory returns a new Memory cache

func (*Memory) DeleteOlderThan

func (m *Memory) DeleteOlderThan(key string, t time.Time) error

DeleteOlderThan deletes a thing older than a timestamp

func (*Memory) GetNewerThan

func (m *Memory) GetNewerThan(key string, t time.Time) *Thing

GetNewerThan returns a thing older than a timestamp

func (*Memory) Initialize

func (m *Memory) Initialize() error

func (*Memory) Save

func (m *Memory) Save() error

func (*Memory) Set

func (m *Memory) Set(key string, t *Thing) error

Set stores a thing into memory

func (*Memory) String

func (m *Memory) String() string

type MySQL

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

func NewMySQL

func NewMySQL(cfg Config) (*MySQL, error)

NewMySQL returns a new MySQL cache

func (*MySQL) DeleteOlderThan

func (m *MySQL) DeleteOlderThan(key string, t time.Time) error

DeleteOlderThan deletes a thing older than a timestamp

func (*MySQL) GetNewerThan

func (m *MySQL) GetNewerThan(key string, t time.Time) *Thing

GetNewerThan returns a Item older than a timestamp

func (*MySQL) Initialize

func (m *MySQL) Initialize() error

func (*MySQL) Save

func (m *MySQL) Save() error

func (*MySQL) Set

func (m *MySQL) Set(key string, th *Thing) error

Set stores a thing

func (*MySQL) String

func (m *MySQL) String() string

type Postgres

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

func NewPostgres

func NewPostgres(cfg Config) (*Postgres, error)

NewPostgres returns a new Postgres cache

func (*Postgres) DeleteOlderThan

func (m *Postgres) DeleteOlderThan(key string, t time.Time) error

DeleteOlderThan deletes a thing older than a timestamp

func (*Postgres) GetNewerThan

func (m *Postgres) GetNewerThan(key string, t time.Time) *Thing

GetNewerThan returns a Item older than a timestamp

func (*Postgres) Initialize

func (m *Postgres) Initialize() error

func (*Postgres) Save

func (m *Postgres) Save() error

func (*Postgres) Set

func (m *Postgres) Set(key string, th *Thing) error

Set stores a thing

func (*Postgres) String

func (m *Postgres) String() string

type Thing

type Thing struct {
	Created time.Time

	PullRequests        []*github.PullRequest
	Issues              []*github.Issue
	PullRequestComments []*github.PullRequestComment
	IssueComments       []*github.IssueComment
	Timeline            []*github.Timeline
	Reviews             []*github.PullRequestReview
	StringBool          map[string]bool
}

Jump to

Keyboard shortcuts

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