package
0.0.0-20230529124418-512269d081cf
Repository: https://github.com/alexz33/utils.git
Documentation: pkg.go.dev
# README
concurrent_map
- sync.Map
- 特点:
- 适用于大量读、少量写的场景(变化较少的缓存)
- 读取、写入和覆盖map不相交的键集合
- 缺点
- 不适用与大量读写的场景
- 特点:
- Map 加锁
- 优点
- 结构简单,适用于所有读写场景
- 缺点
- 采用全局锁,性能较差
- 优点
- concurrent_map
- 特点
- 采用分段锁的概念
- 内部采用读写锁(sync.RWMutex)
- 内部结构
var SHARD_COUNT =32 type ConcurrentMapShared struct { items map[string]interface{} sync.RWMutex }
- 特点
# Functions
No description provided by the author
Contains 判断某个元素是否在slice, array, map中.
ContainsIgnoreCase check if a string (search) is present in a slice of strings (target) regardless of the case.words := []string{"Apple", "Banana", "Cherry", "Date", "Fig", "Grape"}
fmt.Println(ContainsIgnoreCase("apple", words)) // true fmt.Println(ContainsIgnoreCase("BANANA", words)) // true fmt.Println(ContainsIgnoreCase("Cherry", words)) // true fmt.Println(ContainsIgnoreCase("date", words)) // true fmt.Println(ContainsIgnoreCase("fig", words)) // true fmt.Println(ContainsIgnoreCase("grape", words)) // true fmt.Println(ContainsIgnoreCase("kiwi", words)) // false.
CopyShallowMap makes a shallow copy of a map.
Difference returns the difference between two string slices.
Equal reports whether a and b are deeply equal.
Flatten 返回一个新的一维平面数组 Returns a new array that is one-dimensional flat.
*
* @name: InInt64Array
* @descripttion: 是否在Int64列表中
* @param {string} target
* @param {[]string} strArray
* @return {bool}
*/.
*
* @name: InIntArray
* @descripttion: 是否在Int列表中
* @param {string} target
* @param {[]string} strArray
* @return {bool}
*/.
*
* @name: InStringArray
* @descripttion: 是否在字符串列表中
* @param {string} target
* @param {[]string} strArray
* @return {bool}
*/.
JoinInts format int64 to slice like: n1, n2, n3.
No description provided by the author
RemoveDuplicate 删除[]string 中的重复元素.
ReverseStringSlice 反转字符串切片 [site user info 0 ] -> [0 info user site].
SpliteInts split string into int64 slice.
*
* @name: IntArrayEqual
* @descripttion: 判断IntArray是否相等
* @param {[]int} arr1
* @param {[]int} arr2
* @return {bool}
*/.
ToSlice 转换为数组.
UniqueString returns a unique string from a slice.
# Variables
No description provided by the author
# Structs
A "thread" safe map of type string:Anything To avoid lock bottlenecks this map is dived to severel (SHARD_COUNT) map shards.
A "thread“ safe string to anything map.
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author