Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimised search command to get 2x speed #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nginx-cache-inspector
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function print_usage() {
}

## Check the number of arguments.
if [ $# -ne 2 ]; then
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
print_usage
exit 1
fi
Expand All @@ -52,7 +52,7 @@ function get_cache_files() {
local max_parallel=${3-16}
## Get the cache files running grep in parallel for each top level
## cache dir.
find $2 -maxdepth 1 -type d | xargs -P $max_parallel -n 1 grep -Rl "KEY:.*$1" | sort -u
find $2 -maxdepth 1 -type f -mtime -1 | xargs -P $max_parallel -I @@ bash -c 'head -n 2 @@ | tail -1 | awk "{print $2}" | grep "'$1'" && echo @@' | sort -u
} # get_cache_files

## Print the cache item key.
Expand All @@ -64,7 +64,7 @@ function get_cache_item_key() {
## Get a cache item TTL.
## $1 - cache file.
function get_cache_item_ttl() {
od -dL $1 | sed -n '2p' | awk '{print $1 - $2}'
od -dL $1 | sed -n '4p' | awk '{print $2 - $1}'
} # get_cache_item_ttl

## Inspects an item from the given cache zone.
Expand Down