Documentation ¶
Index ¶
- Constants
- Variables
- func ContainString(target string, slice []string) bool
- func EstimateParameters(n uint, p float64) (int64, int64)
- func GenInstanceId() string
- func GenPrimaryCacheKey(instanceId string, tableName string, primaryKey string) string
- func GenPrimaryCachePrefix(instanceId string, tableName string) string
- func GenSearchCacheKey(instanceId string, tableName string, sql string, values ...interface{}) string
- func GenSearchCachePrefix(instanceId string, tableName string) string
- func RandFloat64() float64
- func Set(offset []int64) error
- func ShouldCache(tableName string, tables []string) bool
- type BitSetProvider
- type BloomFilter
- type Pair
Constants ¶
View Source
const (
TangCachePrefix = "TangCache"
)
Variables ¶
View Source
var ErrCacheLoadFailed = errors.New("cache hit, but load value error")
View Source
var ErrCacheUnmarshal = errors.New("cache hit, but unmarshal error")
View Source
var PrimaryCacheHit = errors.New("primary cache hit")
View Source
var SearchCacheHit = errors.New("search cache hit")
Functions ¶
func ContainString ¶
func EstimateParameters ¶
EstimateParameters 根据单位个数和错误率估算所需内存和哈希函数数量 Input: n: number of items, p: the err_rate Output: m: the total Size(bit), k: the hash function number. https://krisives.github.io/bloom-calculator/
func GenInstanceId ¶
func GenInstanceId() string
func GenPrimaryCacheKey ¶
func GenPrimaryCachePrefix ¶
func GenSearchCacheKey ¶
func GenSearchCachePrefix ¶
func ShouldCache ¶
Types ¶
type BitSetProvider ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
func New ¶
func New(m int64, k int64, bitSet BitSetProvider) *BloomFilter
func (*BloomFilter) Add ¶
func (f *BloomFilter) Add(data []byte) error
Click to show internal directories.
Click to hide internal directories.