Documentation
¶
Index ¶
- func ModelMatches(modelName string, patterns []string) bool
- func ValidateModelPatterns(patterns []string) error
- type SyncMap
- func (s *SyncMap[K, V]) Clear()
- func (s *SyncMap[K, V]) Clone() SyncMap[K, V]
- func (s *SyncMap[K, V]) Delete(key K)
- func (s *SyncMap[K, V]) Export() map[K]V
- func (s *SyncMap[K, V]) Grow(size int)
- func (s *SyncMap[K, V]) Keys() []K
- func (s *SyncMap[K, V]) Len() (l int)
- func (s *SyncMap[K, V]) Load(key K) (value V, loaded bool)
- func (s *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (s *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (s *SyncMap[K, V]) Range(f func(key K, value V) (shouldContinue bool))
- func (s *SyncMap[K, V]) Store(key K, value V)
- func (s *SyncMap[K, V]) ToMap() map[K]V
- func (s *SyncMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModelMatches ¶
ModelMatches 检查 modelName 是否匹配给定的模式列表。 空模式列表表示匹配所有模型。先尝试精确匹配,再尝试正则匹配(自动添加 ^$)。
func ValidateModelPatterns ¶
ValidateModelPatterns 校验模式列表的合法性。
Types ¶
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap is like a Go sync.Map but type-safe using generics.
The zero SyncMap is empty and ready for use. A SyncMap must not be copied after first use.
func (*SyncMap[K, V]) Clear ¶ added in v0.0.16
func (s *SyncMap[K, V]) Clear()
Clear removes all entries while keeping the map ready for reuse.
func (*SyncMap[K, V]) Delete ¶
func (s *SyncMap[K, V]) Delete(key K)
Delete deletes the value for a key.
func (*SyncMap[K, V]) Export ¶
func (s *SyncMap[K, V]) Export() map[K]V
Export returns a copy of the map contents.
func (*SyncMap[K, V]) Grow ¶
Grow grows the map to the given size. It can be called before the first write operation used.
func (*SyncMap[K, V]) Keys ¶
func (s *SyncMap[K, V]) Keys() []K
Keys return slice with all map keys.
func (*SyncMap[K, V]) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*SyncMap[K, V]) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*SyncMap[K, V]) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*SyncMap[K, V]) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once. Range does not block other methods on the receiver; even f itself may call any method on m.
func (*SyncMap[K, V]) Store ¶
func (s *SyncMap[K, V]) Store(key K, value V)
Store sets the value for a key.