diff options
Diffstat (limited to 'worker/jmap/cache/session.go')
-rw-r--r-- | worker/jmap/cache/session.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/worker/jmap/cache/session.go b/worker/jmap/cache/session.go new file mode 100644 index 00000000..7126041f --- /dev/null +++ b/worker/jmap/cache/session.go @@ -0,0 +1,32 @@ +package cache + +import ( + "git.sr.ht/~rockorager/go-jmap" +) + +func (c *JMAPCache) GetSession() (*jmap.Session, error) { + buf, err := c.get(sessionKey) + if err != nil { + return nil, err + } + s := new(jmap.Session) + err = unmarshal(buf, s) + if err != nil { + return nil, err + } + return s, nil +} + +func (c *JMAPCache) PutSession(s *jmap.Session) error { + buf, err := marshal(s) + if err != nil { + return err + } + return c.put(sessionKey, buf) +} + +func (c *JMAPCache) DeleteSession() error { + return c.delete(sessionKey) +} + +const sessionKey = "session" |