redis

package
v0.0.0-...-6eca257 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements the stores.Storage interface

func New

func New(hostaddr, password string, db int, maxRetries int, readTimeout string, writeTimeout string) (*Store, error)

New initializes connection to the redis instance.

func (*Store) Close

func (r *Store) Close() error

Close closes the connection to redis.

func (*Store) CreateEntry

func (r *Store) CreateEntry(entry shared.Entry, id, userIdentifier string) error

CreateEntry creates an entry (path->url mapping) and all associated stored data.

func (*Store) DeleteEntry

func (r *Store) DeleteEntry(id string) error

DeleteEntry deletes an entry and all associated stored data.

func (*Store) GetEntryByID

func (r *Store) GetEntryByID(id string) (*shared.Entry, error)

GetEntryByID looks up an entry by its path and returns a pointer to a shared.Entry instance, with the visit count and last visit time set properly.

func (*Store) GetUserEntries

func (r *Store) GetUserEntries(userIdentifier string) (map[string]shared.Entry, error)

GetUserEntries returns all entries that are owned by a given user, in the form of a map of path->shared.Entry

func (*Store) GetVisitors

func (r *Store) GetVisitors(id string) ([]shared.Visitor, error)

GetVisitors returns the full list of visitors for a path.

func (*Store) IncreaseVisitCounter

func (r *Store) IncreaseVisitCounter(id string) error

IncreaseVisitCounter is a no-op and returns nil for all values.

This function is unnecessary for the redis backend: we already have a redis LIST of visitors, and we can derive the visit count by calling redis.client.LLen(list) (which is a constant-time op) during GetEntryByID(). If we want the timestamp of the most recent visit we can pull the most recent visit off with redis.client.LIndex(0) (also constant-time) and reading the timetamp field.

func (*Store) RegisterVisitor

func (r *Store) RegisterVisitor(id, visitID string, visitor shared.Visitor) error

RegisterVisitor adds a shared.Visitor to the list of visits for a path.

Jump to

Keyboard shortcuts

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