title: Redis - monitoring maximum memory before inserts fail?
body: <p>While <a href="https://stackoverflow.com/questions/6450932/redis-monitoring-memory-usage">this Q/A</a> does not address the actual issue of: How to detect with client (eg redis-py) that redis is running out of memory constraint not by machine but by the maxmem configuration? Before inserts fail which command to use in the programm to detect about to be full? <br></p>
  
  <p>My first guess is: <a href="https://redis.io/commands/info" rel="nofollow noreferrer">info</a> and check if <code>used_memory_peak</code> &lt; <code>maxmem</code> setting. Is this correct? </p>
  
  <p>(Besides, for out of machine memory, since defrag, use which setting, none of the returned <code>INFO</code> fields help here)</p>
  
  <p>Well should i just try an insert and see if fail (but that would be after the fact then.)</p>