Commit 6a15c664 authored by Akshay Bharambe's avatar Akshay Bharambe
Browse files

Add: Docs

parent 3e3f6315
Branches
Tags
2 merge requests!173Mep release19032020,!170Add: Functionality to call session manager from bls.
Showing with 5 additions and 1 deletion
......@@ -19,6 +19,7 @@ type Entry struct {
}
const (
// keys for the entry object
KEY_DATA = "data"
KEY_EXPIREDAT = "expiredAt"
KEY_EXPIRATION = "expiration"
......@@ -86,6 +87,9 @@ func ToObject(entry Entry) map[string]interface{} {
func Store(key string, entry Entry) {
duration := time.Duration(entry.Expiration) * time.Second
// if session manager uses redis cache, the data field (gjson.Result) is saved as is.
// This adds irrelevant fields in redis cache and we get them on retrieve operation.
// The followinf operation needs to be performed so thar the data is marshaled correctly. Redis only accepts []byte{}.
if store.Type() == cachemdl.TypeRedisCache {
store.SetWithExpiration(key, NewRedisEntry(entry), duration)
return
......@@ -118,7 +122,7 @@ func Retrieve(key string) (Entry, error) {
}
}
// Delete removes the entry from session manager
// Delete removes the entry from session manager. If the key is not present, error `ErrSessionNotFound` will be thrown. Caller can ignore error if this is acceptable.
func Delete(key string) error {
_, ok := store.Get(key)
if !ok {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment