mapx

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

* @Author: cnzf1 * @Date: 2023-03-28 14:36:32 * @LastEditors: cnzf1 * @LastEditTime: 2023-03-29 13:47:13 * @Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelCallBack

type DelCallBack func(key string, val lang.AnyType)

type EMConfig

type EMConfig struct {
	// contains filtered or unexported fields
}

type EMOption

type EMOption func(*EMConfig)

func WithDelCallback

func WithDelCallback(fn DelCallBack) EMOption

func WithTick

func WithTick(tick time.Duration) EMOption

type ExpiredMap

type ExpiredMap struct {
	// contains filtered or unexported fields
}

func NewExpiredMap

func NewExpiredMap(opts ...EMOption) *ExpiredMap

func (*ExpiredMap) Clear

func (c *ExpiredMap) Clear()

func (*ExpiredMap) Close

func (c *ExpiredMap) Close()

func (*ExpiredMap) Delete

func (c *ExpiredMap) Delete(key string)

func (*ExpiredMap) Foreach

func (c *ExpiredMap) Foreach(fn func(key string, value lang.AnyType))

func (*ExpiredMap) Get

func (c *ExpiredMap) Get(key string) (value lang.AnyType, ok bool)

func (*ExpiredMap) Set

func (c *ExpiredMap) Set(key string, value lang.AnyType, ttl time.Duration) bool

func (*ExpiredMap) Size

func (c *ExpiredMap) Size() int64

func (*ExpiredMap) TTL

func (c *ExpiredMap) TTL(key string) time.Duration

type SafeMap

type SafeMap struct {
	// contains filtered or unexported fields
}

SafeMap provides a map alternative to avoid memory leak. This implementation is not needed until issue below fixed. https://github.com/golang/go/issues/20135

func NewSafeMap

func NewSafeMap() *SafeMap

NewSafeMap returns a SafeMap.

func (*SafeMap) Get

func (m *SafeMap) Get(key any) (any, bool)

Get gets the value with the given key from m.

func (*SafeMap) Range

func (m *SafeMap) Range(f func(key, val any) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*SafeMap) Remove

func (m *SafeMap) Remove(key any)

Remove deletes the value with the given key from m.

func (*SafeMap) Set

func (m *SafeMap) Set(key, value any)

Set sets the value into m with the given key.

func (*SafeMap) Size

func (m *SafeMap) Size() int

Size returns the size of m.

Jump to

Keyboard shortcuts

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