github.com/leslie-fei/fastcache@v0.0.0-20240520092641-b7a9eb05711f/config.go (about)

     1  package fastcache
     2  
     3  import "runtime"
     4  
     5  type MemoryType int
     6  
     7  const (
     8  	GO   MemoryType = 1
     9  	SHM             = 2
    10  	MMAP            = 3
    11  )
    12  
    13  type Config struct {
    14  	// memory type in GO SHM MMAP
    15  	MemoryType MemoryType
    16  	// shard memory key
    17  	MemoryKey string
    18  	// max element length in cache when set value over the length will evict oldest
    19  	MaxElementLength uint64
    20  	// number of shards
    21  	Shards uint32
    22  }
    23  
    24  func DefaultConfig() *Config {
    25  	return &Config{
    26  		MemoryType: GO,
    27  		Shards:     uint32(runtime.NumCPU() * 4),
    28  	}
    29  }