Documentation ¶
Overview ¶
Package enumcache provides a collection of thread-safe methods for storing and retrieving enumeration sets with integer IDs and string names. It includes support for binary maps (github.com/Vonage/gosrvlib/pkg/enumbitmap), where each bit represents a different name in the enumeration set.
Index ¶
- type EnumCache
- func (ec *EnumCache) DecodeBinaryMap(v int) ([]string, error)
- func (ec *EnumCache) EncodeBinaryMap(s []string) (int, error)
- func (ec *EnumCache) ID(name string) (int, error)
- func (ec *EnumCache) Name(id int) (string, error)
- func (ec *EnumCache) Set(id int, name string)
- func (ec *EnumCache) SetAllIDByName(enum IDByName)
- func (ec *EnumCache) SetAllNameByID(enum NameByID)
- func (ec *EnumCache) SortIDs() []int
- func (ec *EnumCache) SortNames() []string
- type IDByName
- type NameByID
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnumCache ¶
EnumCache handles name and id value mapping.
func (*EnumCache) DecodeBinaryMap ¶
DecodeBinaryMap decodes a int binary map into a list of string names. The EnumCache must contain the mapping between the bit values and the names.
func (*EnumCache) EncodeBinaryMap ¶
EncodeBinaryMap encode a list of string names into a int binary map. The EnumCache must contain the mapping between the bit values and the names.
func (*EnumCache) SetAllIDByName ¶
SetAllIDByName sets all the specified enumeration ID values indexed by Name.
func (*EnumCache) SetAllNameByID ¶
SetAllNameByID sets all the specified enumeration Name values indexed by ID.