2014-06-14 20:15:10 +04:00
|
|
|
package store
|
2014-06-13 22:36:36 +04:00
|
|
|
|
2014-06-13 22:42:50 +04:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2014-06-14 20:15:10 +04:00
|
|
|
"github.com/yosssi/boltstore/shared/protobuf"
|
2014-06-13 22:42:50 +04:00
|
|
|
)
|
2014-06-13 22:36:36 +04:00
|
|
|
|
|
|
|
// NewSession creates and returns a session data.
|
2014-06-13 22:42:50 +04:00
|
|
|
func NewSession(values []byte, maxAge int) *protobuf.Session {
|
2014-06-13 22:36:36 +04:00
|
|
|
var expiresAt int64
|
|
|
|
if maxAge > 0 {
|
|
|
|
expiresAt = time.Now().Unix() + int64(maxAge)
|
|
|
|
}
|
2014-06-13 22:42:50 +04:00
|
|
|
return &protobuf.Session{Values: values, ExpiresAt: &expiresAt}
|
2014-06-13 22:36:36 +04:00
|
|
|
}
|