cachepool

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cachepool []byte缓存池

Index

Constants

This section is empty.

Variables

View Source
var (
	//CachePool []byte 缓存池 2
	CachePool = cachePool2{}
)
View Source
var (
	// IDCachePool []byte 缓存池
	IDCachePool = cachePool{
		// contains filtered or unexported fields
	}
)
View Source
var (
	SyncPool = sync.Pool{
		New: func() interface{} {
			syncPoolFirstNew = true
			return RawMallocByteSlice(syncPoolSize)
		},
	}
)

Functions

func Apply

func Apply(size int) (id int32)

Apply 申请缓存, 返回缓存id

func Delete

func Delete(id int32)

Delete 通过缓存id删除缓存

func DeleteAll

func DeleteAll()

DeleteAll 清空缓存池

func Existed

func Existed(id int32) bool

Existed 通过缓存id检测是否存在缓存

func Get

func Get(id int32) []byte

Get 通过缓存id获取缓存[]byte

func RawByteSlice

func RawByteSlice(size int) (b []byte)

RawByteSlice point to runtime.rawbyteslice

func RawMalloc

func RawMalloc(size int) unsafe.Pointer

RawMalloc allocates a new slice. The slice is not zeroed.

func RawMallocByteSlice

func RawMallocByteSlice(size int) []byte

RawMallocByteSlice allocates a new byte slice. The slice is not zeroed.

func Set

func Set(id int32, size int) []byte

Set 设置缓存, 通过给定的缓存id

func SetIfNotExist

func SetIfNotExist(id int32, size int) []byte

SetIfNotExist 如果缓存不存在, 则设置缓存池

func SetSyncPoolSize

func SetSyncPoolSize(size int)

Types

type Cache

type Cache interface {
	Bytes() []byte
	Free()
}

Cache cache

func Require

func Require(size int) Cache

Require 申请Cache

Jump to

Keyboard shortcuts

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