Documentation ¶
Index ¶
Constants ¶
const ( // keys for the entry object KEY_DATA = "data" KEY_EXPIREDAT = "expiredAt" KEY_EXPIRATION = "expiration" )
Variables ¶
Functions ¶
func Delete ¶
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 Init ¶
Init initializes session manager with provided cache. Subsequent calls will not have any effect after first initialization.
func NewRedisEntry ¶
NewRedisEntry prepares the entry for redis cache. This is required because redis accepts a byte array.
func RetrieveAll ¶
func RetrieveAll() map[string]interface{}
RetrieveAll returns all entries present in memory. **Not for production use. May add performance costs**
func Store ¶
Store adds/ updates the entry against the provided key.
Types ¶
type Entry ¶
type Entry struct { Data gjson.Result `json:"data,omitempty"` Expiration int64 `json:"expiration,omitempty"` ExpiredAT int64 `json:"expiredAt,omitempty"` }
Entry is a data to be stored against a key.
func NewEntry ¶
NewEntry prepares the object required to store data in session.
The `exp` field interprets time in seconds. Ex. For 5 seconds, set `5`
func Retrieve ¶
Retrieve returns the entry present against the provided key. If a key is not available or data stored is not of type gjson.Result, a non nil error will be returned
func RetrieveAndDelete ¶
RetrieveAndDelete deletes the entry after first retrieval