remove global context cache
This commit is contained in:
parent
dc08f27b23
commit
769cc16b06
|
@ -45,7 +45,6 @@ type Engine struct {
|
||||||
DatabaseTZ *time.Location // The timezone of the database
|
DatabaseTZ *time.Location // The timezone of the database
|
||||||
|
|
||||||
disableGlobalCache bool
|
disableGlobalCache bool
|
||||||
enableContextCache bool
|
|
||||||
|
|
||||||
tagHandlers map[string]tagHandler
|
tagHandlers map[string]tagHandler
|
||||||
|
|
||||||
|
@ -314,11 +313,6 @@ func (engine *Engine) NewSession() *Session {
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableContextCache will enable or disable context cache
|
|
||||||
func (engine *Engine) EnableContextCache(enabled bool) {
|
|
||||||
engine.enableContextCache = enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the engine
|
// Close the engine
|
||||||
func (engine *Engine) Close() error {
|
func (engine *Engine) Close() error {
|
||||||
return engine.db.Close()
|
return engine.db.Close()
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright 2018 The Xorm Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package xorm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
type cacheContext struct {
|
|
||||||
context.Context
|
|
||||||
values map[string]interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cacheContext) Done() <-chan struct{} {
|
|
||||||
for k := range c.values {
|
|
||||||
delete(c.values, k)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cacheContext) Value(key interface{}) interface{} {
|
|
||||||
return c.values[key.(string)]
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithCacher(ctx context.Context) context.Context {
|
|
||||||
return &cacheContext{
|
|
||||||
Context: ctx,
|
|
||||||
values: make(map[string]interface{}),
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue