https://github.com/redis-field-engineering/redis-smart-cache-cli
https://github.com/redis-field-engineering/redis-smart-cache-cli
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/redis-field-engineering/redis-smart-cache-cli
- Owner: redis-field-engineering
- Created: 2023-03-23T20:56:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-28T17:58:51.000Z (over 1 year ago)
- Last Synced: 2025-01-25T12:09:11.030Z (4 months ago)
- Language: Go
- Size: 825 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
:linkattrs:
:project-owner: redis-field-engineering
:project-name: redis-smart-cache-cli
:project-group: com.redis
:project-version: 0.0.2
:project-url: https://github.com/{project-owner}/{project-name}
:product-name: Redis Smart Cache CLI
:property-prefix: smartcache
:grafana-dir: demo/redis-smart-cache-demo/grafana
:imagesdir: .github/images
:toc:
:toc-placement!:= Redis Smart Cache CLI
The Redis Smart Cache CLI is a tool for managing and configuring https://github.com/redis-field-engineering/redis-smart-cache[Redis Smart Cache].
This CLI lets you view your application's queries, analyze query performance, and select which queries you want cached.
== Installation
=== Homebrew
You can install the Redis Smart Cache CLI by running:
`brew install redis-field-engineering/tap/smart-cache-cli`
=== Download the Binaries
You can also download the Redis Smart Cache CLI binaries directly, select the https://github.com/redis-field-engineering/redis-smart-cache-cli/releases[latest release to download]. We provide builds for Linux, macOS, and Windows, across a variety of architectures.
== Usage
There are two ways to use the CLI:
1. 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.
2. In **scripted mode**, you can run ad-hoc commands. This is useful when scripting interactions with Smart Cache.=== Common Flags
[cols="1,1,1,1,1"]
|===
|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
|
|
| help for smart-cache-cli
||===
=== Interactive
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==== List Queries
The List Queries table shows you the queries that Smart Cache is currently tracking:
image:query-list-table.png[Query List Table]
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.image:query-rule-dialog.png[Query Rule Dialog]
==== List Rules
The List Rules dialog displays the rules currently in force for Smart Cache. You can batch the creation, editing, and deletion of rules.
image:rule-list.png[Rule List]
==== Rule Creation
The Rule Creation dialog allows you to create and prioritize caching rules.
image:rule-creation.png[Rule Creation Dialog]
==== Table List
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.
image:table-list.png[Table List]
=== Non-Interactive Commands
The Smart Cache CLI provides several non-interactive (i.e., scriptable) commands. These include:
1. List Queries
2. Create Rules==== List Queries
The List Queries command lists the queries seen by Smart Cache. Example:
```
smart-cache-cli listqueries
```image:list-queries.png[List Queries]
===== List Queries flags
[cols="1,1,1,1,1"]
|===
|Flag Name|Shortcut|Type|Description|Default|--sortDirection
|-d
|string
|The direction to sort by. Valid options include DESC and ASC.
|DESC|--sortby
|-b
|string
|The column to sort by. Valid options include 'queryTime', 'accessFrequency', 'tables', and 'id'.
|queryTime|===
==== Rule Creation
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:
===== Rule Creation Flags
[cols="1,1,1,1,1"]
|===
|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 `-y` to run this command in non-interactive (i.e., scripted) mode.
|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|===
== Support
{product-name} is supported by Redis, Inc. on a good faith effort basis. To report bugs, request features, or receive assistance, please {project-url}/issues[file an issue].
== License
{product-name} is licensed under the MIT License. Copyright (C) 2023 Redis, Inc.