cache_store

package
v0.0.0-...-58a2b35 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package lru implements an LRU cache.

保存网络中各个节点公钥对应的域名

Index

Constants

This section is empty.

Variables

View Source
var (
	OutFlashTempName = make(chan *FlashName, 100) //存放需要确认构建的临时域名

	OutFlashName = make(chan *FlashName, 100) //存放需要更新的域名

	OutMulticastName = make(chan []byte, 100) //广播需要同步的域名

	VoteAgree    = utils.NewPollManager() //投赞成票
	VoteDisagree = utils.NewPollManager() //投反对票

	Root *Name = NewName(config.C_root_name, []*nodeStore.TempId{}, config.Root_publicKeyStr) //根节点域名

	NameSelf = "" //保存自己的域名,"" = 未查询;"." = 还未注册域名
)
View Source
var (
	OutFindName = make(chan string, 100)
)
View Source
var (
	OutMulticastPKeyName = make(chan []byte, 100) //需要广播同步的公钥

)

Functions

func AddAddressInName

func AddAddressInName(nameStr string, name *Name)

添加一个域名

func AddBuildName

func AddBuildName(name string) (ok bool)

添加一个刚构建的域名

func AddForeverName

func AddForeverName(name *Name)

root recv 添加一个永久域名

func AddKeyName

func AddKeyName(key []byte, name string)

添加一个公钥和域名的对应

func AddSyncMulticastKey

func AddSyncMulticastKey(key []byte, endTime int64)

定时广播需要同步的公钥

func AddSyncMulticastName

func AddSyncMulticastName(name []byte, endTime int64)

定时广播需要同步的域名

func AgreeTempName

func AgreeTempName(name []byte, replyMd5 string)

赞同构建一个临时域名,一共15个,有8个赞同就算通过

func FindKeyName

func FindKeyName(key string) (name string, ok bool)

查找一个公钥base64值的

func FindNameInTemp

func FindNameInTemp(name string) (ok bool)

查找一个临时域名

func GetAddressInName

func GetAddressInName(name string) *nodeStore.TempId

解析一个域名,随机获得域名的地址

func NoticeNameNotExist

func NoticeNameNotExist(name string)

通知一个域名不存在,不用再等待了

func SwitchNameForForever

func SwitchNameForForever(name string)

转换一个注册的临时域名为一个永久域名

Types

type Cache

type Cache struct {
	// MaxEntries is the maximum number of cache entries before
	// an item is evicted. Zero means no limit.
	MaxEntries int

	// OnEvicted optionally specificies a callback function to be
	// executed when an entry is purged from the cache.
	OnEvicted func(key Key, value interface{})
	// contains filtered or unexported fields
}

Cache is an LRU cache. It is not safe for concurrent access.

func NewCache

func NewCache(maxEntries int) *Cache

New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.

func (*Cache) Add

func (c *Cache) Add(key Key, value interface{})

Add adds a value to the cache.

func (*Cache) Clear

func (c *Cache) Clear()

Clear purges all stored items from the cache.

func (*Cache) Get

func (c *Cache) Get(key Key) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Remove

func (c *Cache) Remove(key Key)

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

type FlashName

type FlashName struct {
	Name  string
	Class string
}

type Key

type Key interface{}

A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators

type Name

type Name struct {
	Name string `json:"name"` //域名字符串

	//	Ids        [][]byte      `json:"ids"`        //所有临时id
	//	UpdateTime int64         `json:"updatetime"` //更新在线时间
	Ids       []*nodeStore.TempId `json:"ids"`       //所有临时id
	PublicKey []byte              `json:"publickey"` //公钥
	Exist     bool                `json:"exist"`     //这个域名是否存在,查找域名的时候返回不存在的域名
	// contains filtered or unexported fields
}

func Debug_GetAllName

func Debug_GetAllName() (names []Name)

获得本机保存的所有域名

func FindNameInForever

func FindNameInForever(name string) (ok bool, one *Name)

查找一个永久域名

func NewName

func NewName(name string, ids []*nodeStore.TempId, publicKey []byte) *Name

func (*Name) AddId

func (this *Name) AddId(sid, pid *nodeStore.AddressNet) bool

添加一个临时id

func (*Name) GetIdOne

func (this *Name) GetIdOne() *nodeStore.TempId

随机获取一个地址

func (*Name) JSON

func (this *Name) JSON() []byte

Jump to

Keyboard shortcuts

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