17 lines
349 B
Go
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}
|
|
}
|