示例#1
0
文件: session.go 项目: kellegous/404
func (s *Session) Save(ctx *context.Context) error {
	var buf bytes.Buffer

	if err := s.Encode(&buf); err != nil {
		return err
	}

	wo := rocksdb.NewWriteOptions()
	defer wo.Close()

	return ctx.Db.Put(wo, s.Key, buf.Bytes())
}
示例#2
0
文件: user.go 项目: kellegous/404
func (u *User) Save(ctx *context.Context) error {
	var buf bytes.Buffer

	if err := u.Encode(&buf); err != nil {
		return err
	}

	wo := rocksdb.NewWriteOptions()
	defer wo.Close()

	return ctx.Db.Put(wo, userKeyBytes(u.Id), buf.Bytes())
}
示例#3
0
文件: session.go 项目: kellegous/404
func DeleteSession(ctx *context.Context, id []byte) error {
	wo := rocksdb.NewWriteOptions()
	defer wo.Close()

	return ctx.Db.Delete(wo, id)
}