cache

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	GetKey() string
	GetValue() string
}

Cacher provides a generic interface for storing data in a mongo cache

type Manager

type Manager interface {
	Storer
}

Manager provides a generic interface to key value cache objects in order to build a DataStore

type MongoManager

type MongoManager struct {
	DB *mgo.Database
}

MongoManager cares for the managing of the Mongo Session instance for a mongo cache.

func (*MongoManager) Create

func (m *MongoManager) Create(data SessionCache, collectionName string) error

Create provides a way to Create a cache object that has been stored in Mongo. Assumes the struct passed in has bson parsing parameters provided in the incoming struct. Namely `_id` must be mapped.

func (*MongoManager) Delete

func (m *MongoManager) Delete(k string, collectionName string) error

Delete provides a way to Delete a cache object that has been stored in Mongo

func (*MongoManager) Get

func (m *MongoManager) Get(k string, collectionName string) (*SessionCache, error)

Get provides a way to Get a cache object that has been stored in Mongo

func (*MongoManager) Update

func (m *MongoManager) Update(u SessionCache, collectionName string) error

Update provides a way to Update an old cache object that has been stored in Mongo

type SessionCache

type SessionCache struct {
	ID        string `bson:"_id" json:"id" xml:"id"`
	Signature string `bson:"signature" json:"signature" xml:"signature"`
}

SessionCache allows storing a map between a session ID and a session signature

func (SessionCache) GetKey

func (s SessionCache) GetKey() string

GetKey returns the key of the cached session map

func (SessionCache) GetValue

func (s SessionCache) GetValue() string

GetValue returns session data as a string

type Storer

type Storer interface {
	Create(cacheObject SessionCache, collectionName string) error
	Get(key string, collectionName string) (*SessionCache, error)
	Update(cacheObject SessionCache, collectionName string) error
	Delete(key string, collectionName string) error
}

Storer provides a way to create cache based objects in mongo

Jump to

Keyboard shortcuts

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