Documentation ¶
Index ¶
- Constants
- type ActiveSession
- type CacheManager
- func (c *CacheManager) AddtoCache(payLoad ActiveSession)
- func (c *CacheManager) GetFromCache(key string, cacheType string) (ActiveSession, bool)
- func (c *CacheManager) GetItemFromCache(prodID string) (cachedItem, error)
- func (c *CacheManager) RemoveFromCache(key string, cacheType string)
- func (c *CacheManager) UpdateCacheFromDB(payLoad ...ActiveSession)
- func (c *CacheManager) UpdateCart(payLoad ActiveSession, productID string, operator string)
- func (c *CacheManager) UpdateItemInCache(prodID string, operator string, amt int) error
- type Cart
- type CartItem
- type MerchantSession
- type SessionCopy
- type UserSession
Constants ¶
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 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 ¶
NewUserSession takes in required inputs and returns a new UserSession.
func (*UserSession) GetSessionOwner ¶
func (u *UserSession) GetSessionOwner() (db.User, []CartItem)