Skip to content

Commit

Permalink
Merge branch 'DiceDB:master' into migration-1030
Browse files Browse the repository at this point in the history
  • Loading branch information
c-harish authored Nov 13, 2024
2 parents 2fdc196 + b127d96 commit 74bb176
Show file tree
Hide file tree
Showing 26 changed files with 505 additions and 440 deletions.
45 changes: 24 additions & 21 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ const (
DefaultConfigName string = "dice.toml"
DefaultConfigFilePath string = "./"

EvictSimpleFirst = "simple-first"
EvictAllKeysRandom = "allkeys-random"
EvictAllKeysLRU = "allkeys-lru"
EvictAllKeysLFU = "allkeys-lfu"
EvictBatchKeysLRU string = "batch_keys_lru"

DefaultKeysLimit int = 200000000
DefaultKeysLimit int = 200000000
DefaultEvictionRatio float64 = 0.1
)

var (
Expand All @@ -50,7 +48,8 @@ var (

InitConfigCmd = false

KeysLimit = DefaultKeysLimit
KeysLimit = DefaultKeysLimit
EvictionRatio = DefaultEvictionRatio

EnableProfiling = false

Expand Down Expand Up @@ -97,11 +96,11 @@ type Config struct {
} `mapstructure:"performance"`

Memory struct {
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionPolicy string `mapstructure:"evictionpolicy"`
EvictionRatio float64 `mapstructure:"evictionratio"`
KeysLimit int `mapstructure:"keyslimit"`
LFULogFactor int `mapstructure:"lfulogfactor"`
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionStrategy string `mapstructure:"evictionstrategy"`
EvictionRatio float64 `mapstructure:"evictionratio"`
KeysLimit int `mapstructure:"keyslimit"`
LFULogFactor int `mapstructure:"lfulogfactor"`
} `mapstructure:"memory"`

Persistence struct {
Expand Down Expand Up @@ -181,17 +180,17 @@ var baseConfig = Config{
AdhocReqChanBufSize: 20, // assuming we wouldn't have more than 20 adhoc requests being sent at a time.
},
Memory: struct {
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionPolicy string `mapstructure:"evictionpolicy"`
EvictionRatio float64 `mapstructure:"evictionratio"`
KeysLimit int `mapstructure:"keyslimit"`
LFULogFactor int `mapstructure:"lfulogfactor"`
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionStrategy string `mapstructure:"evictionstrategy"`
EvictionRatio float64 `mapstructure:"evictionratio"`
KeysLimit int `mapstructure:"keyslimit"`
LFULogFactor int `mapstructure:"lfulogfactor"`
}{
MaxMemory: 0,
EvictionPolicy: EvictAllKeysLFU,
EvictionRatio: 0.9,
KeysLimit: DefaultKeysLimit,
LFULogFactor: 10,
MaxMemory: 0,
EvictionStrategy: EvictBatchKeysLRU,
EvictionRatio: DefaultEvictionRatio,
KeysLimit: DefaultKeysLimit,
LFULogFactor: 10,
},
Persistence: struct {
AOFFile string `mapstructure:"aoffile"`
Expand Down Expand Up @@ -366,6 +365,10 @@ func mergeFlagsWithConfig() {
if KeysLimit != DefaultKeysLimit {
DiceConfig.Memory.KeysLimit = KeysLimit
}

if EvictionRatio != DefaultEvictionRatio {
DiceConfig.Memory.EvictionRatio = EvictionRatio
}
}

// This function checks if the config file is present or not at default location or at -c flag location
Expand Down
2 changes: 1 addition & 1 deletion dice.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ AdhocReqChanBufSize = 20
[Memory]
MaxMemory = 0
EvictionPolicy = 'allkeys-lfu'
EvictionRatio = 0.9
EvictionRatio = 0.1
KeysLimit = 200000000
LFULogFactor = 10

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/http/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

var deqRandGenerator *rand.Rand
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%^&*()-=+[]\\;':,.<>/?~.|")
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

func deqRandStr(n int) string {
b := make([]rune, n)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/resp/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var deqRandGenerator *rand.Rand
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%^&*()-=+[]\\;':,.<>/?~.|")
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

var (
deqNormalValues []string
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/websocket/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var deqRandGenerator *rand.Rand
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%^&*()-=+[]\\;':,.<>/?~.|")
var deqRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

var (
deqNormalValues []string
Expand Down
4 changes: 2 additions & 2 deletions internal/eval/bloom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestBloomFilter(t *testing.T) {
store := dstore.NewStore(nil, nil)
store := dstore.NewStore(nil, nil, nil)
// This test only contains some basic checks for all the bloom filter
// operations like BFRESERVE, BFADD, BFEXISTS. It assumes that the
// functions called in the main function are working correctly and
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestBloomFilter(t *testing.T) {
}

func TestGetOrCreateBloomFilter(t *testing.T) {
store := dstore.NewStore(nil, nil)
store := dstore.NewStore(nil, nil, nil)
// Create a key and default opts
key := "bf"
opts := defaultBloomOpts()
Expand Down
8 changes: 0 additions & 8 deletions internal/eval/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,6 @@ var (
Eval: evalLATENCY,
Arity: -2,
}
lruCmdMeta = DiceCmdMeta{
Name: "LRU",
Info: `LRU deletes all the keys from the LRU
returns encoded RESP OK`,
Eval: evalLRU,
Arity: 1,
}
sleepCmdMeta = DiceCmdMeta{
Name: "SLEEP",
Info: `SLEEP sets db to sleep for the specified number of seconds.
Expand Down Expand Up @@ -1495,7 +1488,6 @@ func init() {
DiceCmds["LLEN"] = llenCmdMeta
DiceCmds["LPOP"] = lpopCmdMeta
DiceCmds["LPUSH"] = lpushCmdMeta
DiceCmds["LRU"] = lruCmdMeta
DiceCmds["MGET"] = MGetCmdMeta
DiceCmds["MSET"] = msetCmdMeta
DiceCmds["OBJECT"] = objectCmdMeta
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/countminsketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestCountMinSketch(t *testing.T) {
store := dstore.NewStore(nil, nil)
store := dstore.NewStore(nil, nil, nil)

testCMSInitByDim(t, store)
testCMSInitByProb(t, store)
Expand Down
7 changes: 0 additions & 7 deletions internal/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,6 @@ func evalLATENCY(args []string, store *dstore.Store) []byte {
return clientio.Encode([]string{}, false)
}

// evalLRU deletes all the keys from the LRU
// returns encoded RESP OK
func evalLRU(args []string, store *dstore.Store) []byte {
dstore.EvictAllkeysLRUOrLFU(store)
return clientio.RespOK
}

// evalSLEEP sets db to sleep for the specified number of seconds.
// The sleep time should be the only param in args.
// Returns error response if the time param in args is not of integer format.
Expand Down
Loading

0 comments on commit 74bb176

Please sign in to comment.