本站源代码
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.

31 lines
837B

  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. }
上海开阖软件有限公司 沪ICP备12045867号-1