boltstore/session.go
2014-06-14 03:42:50 +09:00

17 lines
349 B
Go

package boltstore
import (
"time"
"github.com/yosssi/boltstore/protobuf"
)
// NewSession creates and returns a session data.
func NewSession(values []byte, maxAge int) *protobuf.Session {
var expiresAt int64
if maxAge > 0 {
expiresAt = time.Now().Unix() + int64(maxAge)
}
return &protobuf.Session{Values: values, ExpiresAt: &expiresAt}
}