I find configure in this , it just said that the command uses the configure command:
./redis-server <path>/redis.conf
But I have no idea how to write configure. So I found the default configuration in this . But I still do not understand how to set the maximum memory. Does it just add this line to configure?
maxmemory 2mb
By the way, I want to know how much the default memory costs. and I want to set the memory to 2 GB, how to do it?
Then I added this line to redis configure to set maxmemory to 40GB:
maxmemory 41943040
And I use the command in redis-cli:
config get maxmemory
this will show me:
127.0.0.1:6379> config get maxmemory 1) "maxmemory" 2) "41943040"
But, my java program throws an exception similar to this when the key number is around 200000:
Exception in thread "Thread-228" redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memory > 'maxmemory'. at redis.clients.jedis.Protocol.processError(Protocol.java:117) at redis.clients.jedis.Protocol.process(Protocol.java:151) at redis.clients.jedis.Protocol.read(Protocol.java:205) at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297) at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:196) at redis.clients.jedis.Jedis.hmset(Jedis.java:644) at cn.ict.dt2redis.analyser.AbstractAnalyser.pushOne(AbstractAnalyser.java:21) at cn.ict.dt2redis.analyser.BatchAbstractAnalyser.run(BatchAbstractAnalyser.java:16) at java.lang.Thread.run(Thread.java:722)
I have no idea if I managed to set the maximum memory to 40 GB? How to do it? please give me the code in detail.
redis
v11
source share