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 access frequency, 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 listqueries
The makerule
command lets you create rules on the fly. This command is non-interactive (i.e., scriptable) when you include the y
flag (to confirm rule creation). See the flag 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 |
--confirm |
-y |
Provide this flag with a value of |
no |
|
--queryIds |
-q |
string |
Comma-delimited unordered list of the IDs of the queries that the rule will apply to. |
no |
--regex |
-r |
string |
The regex to use to match this rule. If the regex matches, the rule will apply. |
no |
--tablesAll |
-l |
string |
Comma-delimited unordered set of table names. Matches if all of these tables in the set appear in the query (other tables may appear, as well). |
no |
--tablesAny |
-x |
string |
Comma-delimited unordered set of table names. Matches if any of these tables appear in the query. |
no |
--tablesExact |
-e |
string |
Comma-delimited unordered set of table names. Matches of all of these tables – and no others – appear in the query. |
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.