// InitSessionManagerCache initializes the cache with provided configuration. Need to provide a cache type to use.
funcInitSessionManagerCache(chacheTypeint){
cacheConfig:=cachemdl.CacheConfig{
Type:chacheType,
RedisCache:&cachemdl.RedisCache{
Addr:"",
DB:models.RedisDBSessionManager,
Prefix:models.ProjectID,
},
FastCache:&cachemdl.FastCacheHelper{
CleanupTime:60*time.Minute,
MaxEntries:1000,
Expiration:-1,
},
}
store=cachemdl.GetCacheInstance(&cacheConfig)
}
funcNewEntry(valgjson.Result,expint64)Entry{
duration:=time.Duration(exp)*time.Second
deadLine:=time.Now().Add(duration).Unix()
returnEntry{
Data:val,
Expiration:exp,
ExpiredAT:deadLine,
}
}
// Store adds/ updates the entry against the provided key.
funcStore(keystring,entryEntry){
duration:=time.Duration(entry.Expiration)
// deadLine := time.Now().Add(duration).Unix()
// entry := Entry{
// Data: val,
// Expiration: exp,
// ExpiredAT: deadLine,
// }
store.SetWithExpiration(key,entry,duration)
}
// Retrive 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