MCPcopy Create free account
hub / github.com/kataras/iris / Decode

Method Decode

sessions/sessiondb/boltdb/database.go:294–313  ·  view source on GitHub ↗

Decode binds the "outPtr" to the value associated to the provided "key".

(sid, key string, outPtr interface{})

Source from the content-addressed store, hash-verified

292
293// Decode binds the "outPtr" to the value associated to the provided "key".
294func (db *Database) Decode(sid, key string, outPtr interface{}) error {
295 err := db.Service.View(func(tx *bolt.Tx) error {
296 b := db.getBucketForSession(tx, sid)
297 if b == nil {
298 return nil
299 }
300
301 valueBytes := b.Get(makeKey(key))
302 if len(valueBytes) == 0 {
303 return nil
304 }
305
306 return sessions.DefaultTranscoder.Unmarshal(valueBytes, outPtr)
307 })
308 if err != nil {
309 db.logger.Debugf("session '%s' key '%s' cannot be retrieved: %v", sid, key, err)
310 }
311
312 return err
313}
314
315// Visit loops through all session keys and values.
316func (db *Database) Visit(sid string, cb func(key string, value interface{})) error {

Callers 1

GetMethod · 0.95

Calls 5

getBucketForSessionMethod · 0.95
makeKeyFunction · 0.70
ViewMethod · 0.65
GetMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected