redis / jedis

Redis Java client
MIT License
11.85k stars 3.87k forks source link

Jedis Memory commands, ex memory usage, memory stats #1959

Closed sabeehshah closed 2 years ago

sabeehshah commented 5 years ago

I want to get the memory usage per key that is being by redis cache. I tried using the Connection class method sendCommand but to no luck because i don't think it has existing functionality for the Memory commands.

jedis:2.9.0 redis:4.0.11

Leeviiii commented 5 years ago

Do you mean "info memory" in redis? jedis.info() function can get the memory info. jedis only have info function , no "info memory" commands

jedis:3.0.1 redis:4.0.9

marcosnils commented 5 years ago

Do you mean "info memory" in redis?

Nope, I believe he's asking about the MEMORY (https://redis.io/commands/memory-help) commands.

sabeehshah commented 5 years ago

^ yeah those ones.

maksymkovalenko commented 5 years ago

Yeah, ideally MEMORY should be supported just like some other commands. For now, just use INFO memory command. Something like

String s = jedis.info("memory");
Properties props = Properties.load(new StringReader(s));
props.get("used_memory");
/* Props from documentation:
used_memory:193581208
used_memory_human:184.61M
used_memory_rss:207888384
used_memory_rss_human:198.26M
used_memory_peak:199361424
used_memory_peak_human:190.13M
used_memory_peak_perc:97.10%
used_memory_overhead:60022312
used_memory_startup:510704
used_memory_dataset:133558896
used_memory_dataset_perc:69.18%
allocator_allocated:193574472
allocator_active:193900544
allocator_resident:206139392
total_system_memory:1044770816
total_system_memory_human:996.37M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.00
allocator_frag_bytes:326072
allocator_rss_ratio:1.06
allocator_rss_bytes:12238848
rss_overhead_ratio:1.01
rss_overhead_bytes:1748992
mem_fragmentation_ratio:1.07
mem_fragmentation_bytes:14390192
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0
*/

https://redis.io/commands/info

billoneil commented 3 years ago

@gkorland what happened to this commit did it never make it? Seems like the commit is dangling and never made it into master. https://github.com/redis/jedis/commit/d1a692c79bca7b8434e8aac4b31f58cd54f972eb

sazzad16 commented 3 years ago

@billoneil This is weird. Thanks for noticing.

sazzad16 commented 2 years ago

Resolved by #2279 & #2908

pratik-patil-polestar commented 7 months ago

Yeah, ideally MEMORY should be supported just like some other commands. For now, just use INFO memory command. Something like

String s = jedis.info("memory");
Properties props = Properties.load(new StringReader(s));
props.get("used_memory");
/* Props from documentation:
used_memory:193581208
used_memory_human:184.61M
used_memory_rss:207888384
used_memory_rss_human:198.26M
used_memory_peak:199361424
used_memory_peak_human:190.13M
used_memory_peak_perc:97.10%
used_memory_overhead:60022312
used_memory_startup:510704
used_memory_dataset:133558896
used_memory_dataset_perc:69.18%
allocator_allocated:193574472
allocator_active:193900544
allocator_resident:206139392
total_system_memory:1044770816
total_system_memory_human:996.37M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.00
allocator_frag_bytes:326072
allocator_rss_ratio:1.06
allocator_rss_bytes:12238848
rss_overhead_ratio:1.01
rss_overhead_bytes:1748992
mem_fragmentation_ratio:1.07
mem_fragmentation_bytes:14390192
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0
*/

https://redis.io/commands/info

While using memoryUsage(key)method of Jedis i am getting this following error "errorMessage": "ERR unknown command 'memory', with args beginning with: USAGE" is it possible that this method is not allowed on AWS ElastiCache

sazzad16 commented 7 months ago

is it possible that this method is not allowed on AWS ElastiCache

@pratik-patil-polestar ask AWS ElastiCache. thank you