cache

package
v0.0.0-...-e09fbcc Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionLife = 30 // default life of active session in minutes.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveSession

type ActiveSession interface {
	// contains filtered or unexported methods
}

ActiveSession interface contains methods to manipulate session Data.

type CacheManager

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

CacheManager stores the various cache types and has CRUD functionality to access the underlying cache methods.

func NewCacheManager

func NewCacheManager(database *db.Database) *CacheManager

NewCacheManager returns a pointer to an initialized CacheManager.

func (*CacheManager) AddtoCache

func (c *CacheManager) AddtoCache(payLoad ActiveSession)

AddtoCache identifies the type of the payload before adding it into the respective cache by calling on the respective cache.add() method.

func (*CacheManager) GetFromCache

func (c *CacheManager) GetFromCache(key string, cacheType string) (ActiveSession, bool)

GetFromCache identifies the type of the payload before retrieving it from the respective cache by calling on the respective cache.get() method.

func (*CacheManager) GetItemFromCache

func (c *CacheManager) GetItemFromCache(prodID string) (cachedItem, error)

func (*CacheManager) RemoveFromCache

func (c *CacheManager) RemoveFromCache(key string, cacheType string)

RemoveFromCache identifies the type of hte payload before removing it from the respective cache by calling on the respective cache.remove() method.

func (*CacheManager) UpdateCacheFromDB

func (c *CacheManager) UpdateCacheFromDB(payLoad ...ActiveSession)

UpdateCacheFromDB feeds an array of the payload which is obtained from the latest DB query and calls on the respective cache's cache.update() method.

func (*CacheManager) UpdateCart

func (c *CacheManager) UpdateCart(payLoad ActiveSession, productID string, operator string)

UpdateCache identifies the type of the payload before adding it into the respective cache by calling on the respective cache.updateExpiryTime() method. In the case of a user updating their cart, UpdateCache also updates the respective product cart.

func (*CacheManager) UpdateItemInCache

func (c *CacheManager) UpdateItemInCache(prodID string, operator string, amt int) error

type Cart

type Cart []CartItem

func (Cart) GrandTotal

func (c Cart) GrandTotal() float64

type CartItem

type CartItem struct {
	Product db.Product
	Count   int
}

func (CartItem) Total

func (c CartItem) Total(quantity int, price float64) float64

func (CartItem) Value

func (c CartItem) Value() float64

type MerchantSession

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

MerchantSession implements the ActiveSession interface by embedding the session struct. stores information about the logged in merchant user.

func NewMerchSession

func NewMerchSession(sessionKey string, expiry time.Time, user db.MerchantUser) *MerchantSession

NewMerchantSession takes in required inputs and returns a new MerchantSession

func (*MerchantSession) GetSessionOwner

func (m *MerchantSession) GetSessionOwner() db.MerchantUser

type SessionCopy

type SessionCopy interface {
	Data()
}

type UserSession

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

UserSession implements the ActiveSession interface by embedding the session struct. Stores information about the logged in user and his cart data.

func NewUserSession

func NewUserSession(sessionKey string, expiry time.Time, user db.User, cart Cart) *UserSession

NewUserSession takes in required inputs and returns a new UserSession.

func (*UserSession) GetSessionOwner

func (u *UserSession) GetSessionOwner() (db.User, []CartItem)

Jump to

Keyboard shortcuts

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