Create & Init Project...
This commit is contained in:
32
library/cache/memcache/util.go
vendored
Normal file
32
library/cache/memcache/util.go
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package memcache
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
// RawItem item with FlagRAW flag.
|
||||
//
|
||||
// Expiration is the cache expiration time, in seconds: either a relative
|
||||
// time from now (up to 1 month), or an absolute Unix epoch time.
|
||||
// Zero means the Item has no expiration time.
|
||||
func RawItem(key string, data []byte, flags uint32, expiration int32) *Item {
|
||||
return &Item{Key: key, Flags: flags | FlagRAW, Value: data, Expiration: expiration}
|
||||
}
|
||||
|
||||
// JSONItem item with FlagJSON flag.
|
||||
//
|
||||
// Expiration is the cache expiration time, in seconds: either a relative
|
||||
// time from now (up to 1 month), or an absolute Unix epoch time.
|
||||
// Zero means the Item has no expiration time.
|
||||
func JSONItem(key string, v interface{}, flags uint32, expiration int32) *Item {
|
||||
return &Item{Key: key, Flags: flags | FlagJSON, Object: v, Expiration: expiration}
|
||||
}
|
||||
|
||||
// ProtobufItem item with FlagProtobuf flag.
|
||||
//
|
||||
// Expiration is the cache expiration time, in seconds: either a relative
|
||||
// time from now (up to 1 month), or an absolute Unix epoch time.
|
||||
// Zero means the Item has no expiration time.
|
||||
func ProtobufItem(key string, message proto.Message, flags uint32, expiration int32) *Item {
|
||||
return &Item{Key: key, Flags: flags | FlagProtobuf, Object: message, Expiration: expiration}
|
||||
}
|
Reference in New Issue
Block a user