diff --git a/context.go b/context.go index 0ae8b5bc..fb7f54e9 100644 --- a/context.go +++ b/context.go @@ -53,8 +53,6 @@ type Context struct { engine *Engine - EnableMutexLock bool - // This mutex protect Keys map mu sync.RWMutex @@ -235,27 +233,21 @@ func (c *Context) Error(err error) *Error { // Set is used to store a new key/value pair exclusively for this context. // It also lazy initializes c.Keys if it was not used previously. func (c *Context) Set(key string, value interface{}) { - if c.EnableMutexLock { - c.mu.Lock() - defer c.mu.Unlock() - } - + c.mu.Lock() if c.Keys == nil { c.Keys = make(map[string]interface{}) } c.Keys[key] = value + c.mu.Unlock() } // Get returns the value for the given key, ie: (value, true). // If the value does not exists it returns (nil, false) func (c *Context) Get(key string) (value interface{}, exists bool) { - if c.EnableMutexLock { - c.mu.RLock() - defer c.mu.RUnlock() - } - + c.mu.RLock() value, exists = c.Keys[key] + c.mu.RUnlock() return }