You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

context_cache.go 837B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2018 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. // ContextCache is the interface that operates the cache data.
  6. type ContextCache interface {
  7. // Put puts value into cache with key.
  8. Put(key string, val interface{})
  9. // Get gets cached value by given key.
  10. Get(key string) interface{}
  11. }
  12. type memoryContextCache map[string]interface{}
  13. // NewMemoryContextCache return memoryContextCache
  14. func NewMemoryContextCache() memoryContextCache {
  15. return make(map[string]interface{})
  16. }
  17. // Put puts value into cache with key.
  18. func (m memoryContextCache) Put(key string, val interface{}) {
  19. m[key] = val
  20. }
  21. // Get gets cached value by given key.
  22. func (m memoryContextCache) Get(key string) interface{} {
  23. return m[key]
  24. }