Documentation ¶
Index ¶
- type Store
- func (r *Store) Close() error
- func (r *Store) CreateEntry(entry shared.Entry, id, userIdentifier string) error
- func (r *Store) DeleteEntry(id string) error
- func (r *Store) GetEntryByID(id string) (*shared.Entry, error)
- func (r *Store) GetUserEntries(userIdentifier string) (map[string]shared.Entry, error)
- func (r *Store) GetVisitors(id string) ([]shared.Visitor, error)
- func (r *Store) IncreaseVisitCounter(id string) error
- func (r *Store) RegisterVisitor(id, visitID string, visitor shared.Visitor) error
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) CreateEntry ¶
CreateEntry creates an entry (path->url mapping) and all associated stored data.
func (*Store) DeleteEntry ¶
DeleteEntry deletes an entry and all associated stored data.
func (*Store) GetEntryByID ¶
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 ¶
GetUserEntries returns all entries that are owned by a given user, in the form of a map of path->shared.Entry
func (*Store) GetVisitors ¶
GetVisitors returns the full list of visitors for a path.
func (*Store) IncreaseVisitCounter ¶
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.