pool

package
v2.0.0-...-288f5f8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

The pool subpackage is the new hashmap cache pool, which is only for testing now.

It will replace the Context cache pool in the future.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnavaCmpAlg      = errors.New("unavailable compression algorithms")
	ErrDisableSwitchCmp = errors.New("disable switching of compression algorithm in a pool that has completed compression initialization")
)

Functions

This section is empty.

Types

type MessageSession

type MessageSession struct {
	ID        string // Session ID
	Messages  data.MessageArray
	RawData   []byte // Unprocessed raw json data returned by the API endpoint
	Response  resp.Response
	ErrorResp *resp.ErrorResponse
}

type Pool

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

func New

func New() *Pool

Create a new pool in cached mode.

func (*Pool) Append

func (p *Pool) Append(k, v string) bool

Append will take out the data, and then append a new piece of data to the end before saving it.

func (*Pool) Del

func (p *Pool) Del(k string) bool

Del deletes the key from the map and returns whether the key was deleted.

func (*Pool) Get

func (p *Pool) Get(k string) (string, bool)

Get retrieves an element from the map under given hash key.

func (*Pool) Insert

func (p *Pool) Insert(k, v string) bool

Insert sets the value under the specified key to the map if it does not exist yet. If a resizing operation is happening concurrently while calling Insert, the item might show up in the map after the resize operation is finished. Returns true if the item was inserted or false if it existed.

func (*Pool) Len

func (p *Pool) Len() int

Len returns the number of elements within the map.

func (*Pool) Range

func (p *Pool) Range(f func(k string, v string) bool)

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

func (*Pool) ResetPool

func (p *Pool) ResetPool()

Flush will clear all data in the Pool.

func (*Pool) Set

func (p *Pool) Set(k, v string) bool

Set sets the value under the specified key to the map. An existing item for this key will be overwritten. If a resizing operation is happening concurrently while calling Set, the item might show up in the map after the resize operation is finished.

func (*Pool) UseCompress

func (p *Pool) UseCompress(compress compress.Interface) error

Enable Compress (no use)

type Session

type Session struct {
	ID        string // Session ID
	Human     string
	RawData   []byte // Unprocessed raw json data returned by the API endpoint
	Response  resp.Response
	ErrorResp *resp.ErrorResponse
}

Jump to

Keyboard shortcuts

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