slorello89 / redis-smart-cache-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis Smart Cache CLI

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.

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 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

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

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:

  1. List Queries

  2. Rule List

  3. Create Rule

  4. Table List

List Queries

The List Queries table shows you the queries that Smart Cache is currently tracking:

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.

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.

Rule List

Rule Creation

The Rule Creation dialog allows you to create and prioritize caching rules.

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 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.

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 list-queries

List Queries

List Queries flags
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 make-rule command lets you create rules on the fly. This command is non-interactive. See the option descriptions below for details:

Rule Creation Options
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

Support

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.

License

Redis Smart Cache CLI is licensed under the MIT License. Copyright © 2023 Redis, Inc.

About

License:MIT License


Languages

Language:Java 99.1%Language:Smarty 0.9%