-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2c8790
commit 2fdb668
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
First, setup redis: bash setup.sh to install redis in ubuntu for thest | ||
|
||
To test, fill a prefix with some random keys (1k each) | ||
bash fill.sh <prefix> <n> | ||
|
||
Then you can check providing the prefixes to check (as I assume we know them )"" | ||
|
||
bash check.sh <prefx> <prefix>... | ||
|
||
Example | ||
|
||
``` | ||
bash fill.sh mike 100 | ||
bash check.sh mike franz | ||
bash fill.sh franz 200 | ||
bash check.sh mike franz | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
SCRIPT=$(redis-cli SCRIPT LOAD "$(cat size_by_prefix.lua)") | ||
for i in "$@" | ||
do redis-cli EVALSHA $SCRIPT 0 "$i:" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
PREFIX=${1?:prefix} | ||
N=${2?:count} | ||
X=$(printf "x%.0s" {1..1024}) | ||
for i in $(seq 1 $N) | ||
do K=$RANDOM | ||
echo $i $K | ||
redis-cli set $PREFIX:$K "$X" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sudo apt-get install redis-server redis-tools | ||
sudo systemctl start redis-server | ||
sudo systemctl status redis-server | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Define the key prefix to search for | ||
local prefix = ARGV[1] | ||
local cursor = 0 | ||
local total_memory = 0 | ||
|
||
repeat | ||
-- Use SCAN to get keys that match the prefix | ||
local result = redis.call('SCAN', cursor, 'MATCH', prefix .. '*') | ||
cursor = tonumber(result[1]) | ||
local keys = result[2] | ||
|
||
for _, key in ipairs(keys) do | ||
-- Get memory usage of each key and add it to the total | ||
local memory_usage = redis.call('MEMORY', 'USAGE', key) | ||
if memory_usage then | ||
total_memory = total_memory + memory_usage | ||
end | ||
end | ||
until cursor == 0 | ||
|
||
return total_memory |