Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReleaseCtx ¶ added in v0.1.4
func ReleaseCtx(ctx Context)
ReleaseCtx returns ctx acquired via AcquireCtx to Context pool.
It is forbidden accessing ctx and/or its' members after returning it to Context pool.
Types ¶
type Context ¶
type Context interface { // Get 通过 key 在上下文中获取一个字符串 Get(key string) string // GetAny 通过 key 在上下文中获取一个任意类型 GetAny(key string) interface{} // Put 向上下文中传入一个 key: value Put(key string, val interface{}) // GetAndDelete 获取并删除一个 key GetAndDelete(key string) interface{} // Delete 在上下文中删除指定的 key Delete(key string) // ForEach 将上下文中的全部 key 和 value 用传 // 入的函数处理后返回一个处理结果的切片 ForEach(func(key string, val interface{}) interface{}) []interface{} // Clear 清空一个上下文 Clear() // Length 返回上下文的长度 Length() int // String 将上下文转换为 json(非标准) 字符串 String() string // Bytes 格式化为 json 用的字节切片 Bytes() []byte }
func AcquireCtx ¶ added in v0.1.4
AcquireCtx returns an empty Context instance from context pool.
The returned Context instance may be passed to ReleaseCtx when it is no longer needed. This allows Context recycling, reduces GC pressure and usually improves performance.
func NewContext ¶
NewContext returns a new Context instance
Click to show internal directories.
Click to hide internal directories.