remove global context cache

This commit is contained in:
Lunny Xiao 2018-09-18 15:18:21 +08:00
parent dc08f27b23
commit 769cc16b06
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 0 additions and 38 deletions

View File

@ -45,7 +45,6 @@ type Engine struct {
DatabaseTZ *time.Location // The timezone of the database
disableGlobalCache bool
enableContextCache bool
tagHandlers map[string]tagHandler
@ -314,11 +313,6 @@ func (engine *Engine) NewSession() *Session {
return session
}
// EnableContextCache will enable or disable context cache
func (engine *Engine) EnableContextCache(enabled bool) {
engine.enableContextCache = enabled
}
// Close the engine
func (engine *Engine) Close() error {
return engine.db.Close()

View File

@ -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{}),
}
}