gostore

package module
v0.0.0-...-0bcd41c Latest Latest
Warning

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

Go to latest
Published: May 29, 2017 License: MIT Imports: 4 Imported by: 1

README

gstore

gostore is an in-memory key/value store that can support list and callback triggers

Build Status

Documentation

Overview

Package gostore is an in-memory key/value store

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	ID    string      // the unique item ID
	Key   string      // the key in the key/value store
	Value interface{} // the value in the key/value store
	// contains filtered or unexported fields
}

Item is the item to be stored

type Store

type Store interface {

	// Init initializes the store
	Init()

	// Close stops all internal goroutines
	Close()

	// Put saves the item in the store given an optional expiry duration.
	Put(item *Item, d time.Duration) error

	// Get returns the item given the key
	Get(key string) (item *Item, found bool, err error)

	// Del deletes the item for the key
	Del(key string) error

	// ListPush adds the item to the list of items
	ListPush(key string, value *Item) error

	// ListGet returns the list of items given a key
	ListGet(key string) (items []*Item, found bool, err error)

	// ListDel deletes the item from the list
	ListDel(key string, value *Item) error

	// OnItemDidExpire adds the callback function to the list off callback functions
	// called when an item expires
	OnItemDidExpire(func(item *Item))

	// OnListDidChange adds a callback to change in list
	OnListDidChange(func(key string, items []*Item))
}

Store is the interface to the in-memory store

func NewStore

func NewStore() Store

NewStore returns a new instance of Store

Jump to

Keyboard shortcuts

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