The Redis Smart Cache CLI is a tool for managing and configuring Redis Smart Cache.
This CLI lets you view your application’s queries, analyze query performance, and select which queries you want cached.
You can install the Redis Smart Cache CLI by running:
brew install redis-field-engineering/tap/smart-cache-cli
You can also download the Redis Smart Cache CLI binaries directly, select the latest release to download. We provide builds for Linux, macOS, and Windows, across a variety of architectures.
There are two ways to use the CLI:
-
In interactive mode, you can navigate the CLI’s menus to observe the queries and tables being profiled by Smart Cache. You can then apply updates to the rules used to guide Smart Cache’s caching decisions.
-
In scripted mode, you can run ad-hoc commands. This is useful when scripting interactions with Smart Cache.
Flag Name | Shortcut | Type | Description | Default |
---|---|---|---|---|
--application |
-s |
string |
The application namespace to use |
smartcache |
--host |
-n |
string |
Host to connect to Redis on |
localhost |
--port |
-p |
string |
Port to connect to Redis on |
6379 |
--user |
-u |
string |
User to authenticate to Redis with |
default |
--password |
-a |
string |
Redis password |
--help |
To run Redis Smart Cache CLI in interactive mode, execute smart-cache-cli
with the flags needed to connect to your Redis instance. You’ll then see a text-based dialog with the following options:
-
List Queries
-
Rule List
-
Create Rule
-
Table List
The List Queries table shows you the queries that Smart Cache is currently tracking:
This dialog lets you choose which queries you want to create rules for. To create a pending rule for a given query, select the query you want and then press return. This will open a rule dialog which will show you expanded details for the query. You can then provide a TTL, which will enable caching for this query.
The List Rules dialog displays the rules currently in force for Smart Cache. You can batch the creation, editing, and deletion of rules.
The Table List view provides you a table-level view of the profiling done by Smart Cache.
You can see your tables, their query counts, and the mean query time for all queries executed against them. You can also see whether a query is cached, including the configured TTL for any cached queries.
The Smart Cache CLI provides several non-interactive (i.e., scriptable) commands. These include:
-
List Queries
-
Create Rules
The List Queries command lists the queries seen by Smart Cache. Example:
smart-cache-cli list-queries
The make-rule
command lets you create rules on the fly. This command is non-interactive. See the option descriptions below for details:
Flag Name | Shortcut | Type | Description | required |
---|---|---|---|---|
--ttl |
-t |
string |
The time to live as a duration (e.g. 5m, 300s, 2d) the rule. Essentially, this is how long the query will be cached for. |
yes |
--type |
-k |
string |
The rule type for the rule, valid values are 'any', 'tables-any', 'tables-exact', 'tables-all', 'query-ids', 'regex' |
yes |
--match |
-m |
string |
What the rule will match against, not required if type is 'any'. Either a comma-delimited list of matches, or a regex. |
no |
Redis Smart Cache CLI is supported by Redis, Inc. on a good faith effort basis. To report bugs, request features, or receive assistance, please file an issue.