Skip to content

Commit

Permalink
narrow down redis info scope and switch to "used_memory_dataset"
Browse files Browse the repository at this point in the history
There is no need to fetch full server info, we only read from the memory
section. Also, "used_memory" might be misleading as this represents the
total memory allocation of the server instance. It may be confusing if
there are several megabyes allocated after flushing the cache, so
"used_memory_dataset" which subtracts the internal overhead is closer to
what a user might expect to see here.
  • Loading branch information
stklcode committed Jun 23, 2024
1 parent 49e0a00 commit d2e705b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inc/class-cachify-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ public static function get_stats() {
}

/* Info */
$data = self::$_redis->info();
$data = self::$_redis->info( 'MEMORY' );

/* No stats? */
if ( empty( $data ) ) {
return null;
}

/* Empty */
if ( empty( $data['used_memory'] ) ) {
if ( empty( $data['used_memory_dataset'] ) ) {
return null;
}

return $data['used_memory'];
return $data['used_memory_dataset'];
}

/**
Expand Down

0 comments on commit d2e705b

Please sign in to comment.