diff --git a/config/config.go b/config/config.go index 12a9f872f..83c7f25b6 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,8 @@ const ( EvictAllKeysRandom = "allkeys-random" EvictAllKeysLRU = "allkeys-lru" EvictAllKeysLFU = "allkeys-lfu" + + DefaultKeysLimit int = 200000000 ) var ( @@ -44,6 +46,8 @@ var ( FileLocation = utils.EmptyStr InitConfigCmd = false + + KeysLimit = DefaultKeysLimit ) type Config struct { @@ -114,7 +118,7 @@ var baseConfig = Config{ MaxMemory: 0, EvictionPolicy: EvictAllKeysLFU, EvictionRatio: 0.9, - KeysLimit: 200000000, + KeysLimit: DefaultKeysLimit, AOFFile: "./dice-master.aof", PersistenceEnabled: true, WriteAOFOnCleanup: false, @@ -293,6 +297,10 @@ func mergeFlagsWithConfig() { if Port != DefaultPort { DiceConfig.Server.Port = Port } + + if KeysLimit != DefaultKeysLimit { + DiceConfig.Server.KeysLimit = KeysLimit + } } // This function checks if the config file is present or not at ConfigFileLocation diff --git a/main.go b/main.go index d68485092..50bc02886 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,9 @@ func init() { flag.StringVar(&config.CustomConfigFilePath, "o", config.CustomConfigFilePath, "dir path to create the config file") flag.StringVar(&config.FileLocation, "c", config.FileLocation, "file path of the config file") flag.BoolVar(&config.InitConfigCmd, "init-config", false, "initialize a new config file") + flag.IntVar(&config.KeysLimit, "keys-limit", config.KeysLimit, "keys limit for the dice server. "+ + "This flag controls the number of keys each shard holds at startup. You can multiply this number with the "+ + "total number of shard threads to estimate how much memory will be required at system start up.") flag.Parse() config.SetupConfig()