cache

package
v0.0.0-...-f0b2648 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2019 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResourceNodes *ResourceNodeList // 所有节点
	IsReData      bool              // 正在重新获取数据库中的数据并重建某个索引
	Mux           sync.Mutex

	Tree        *TreeCache // 缓存所有节点的树
	UserTreeLRU *LRU       // 缓存用户有权限节点的子树
	ResourceLRU *LRU2      // 缓存资源与其他资源的关联图

	NodePool = sync.Pool{
		New: func() interface{} {
			return &model.ResourceNode{}
		},
	}
)

Functions

func NewTreeByPermission

func NewTreeByPermission(permissionSet map[int]struct{}) (*model.Tree, error)

Types

type CacheList

type CacheList struct {
	UserCacheHead *CacheNode
	Size          int64
}

环形双向链表

type CacheNode

type CacheNode struct {
	Key  int
	Val  interface{}
	Pre  *CacheNode
	Next *CacheNode
}

链表节点

type LRU

type LRU struct {
	Index map[int]*CacheNode
	Data  *CacheList
	// contains filtered or unexported fields
}

func (*LRU) Get

func (l *LRU) Get(key int) (interface{}, error)

func (*LRU) Set

func (l *LRU) Set(key int, value interface{})

type LRU2

type LRU2 struct {
	Cache1 *LRU
	Cache2 *LRU

	Version int
	// contains filtered or unexported fields
}

func (*LRU2) Get

func (l2 *LRU2) Get(key int) (interface{}, error)

func (*LRU2) Set

func (l2 *LRU2) Set(keys []int, value interface{})

type ResourceNodeList

type ResourceNodeList struct {
	Data    []*model.ResourceNode
	Version int

	ReData    []*model.ResourceNode
	ReVersion int
}

type TreeCache

type TreeCache struct {
	Tree    *model.Tree
	Index   []*model.Tree
	Size    int
	Version int

	ReTree    *model.Tree
	ReIndex   []*model.Tree
	ReSize    int
	ReVersion int
}

func (*TreeCache) Get

func (tc *TreeCache) Get() (*model.Tree, error)

func (*TreeCache) GetTreeNode

func (tc *TreeCache) GetTreeNode(nodeId int) (*model.Tree, error)

根据节点ID获取以该节点为root的子树

func (*TreeCache) Set

func (tc *TreeCache) Set(version int, data []*model.DBResourceNode) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL