mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-09-26 20:11:15 +08:00
Added docs folder at the project root. Added build_docs and publish_d… (#105)
Docs sub-directory added to the project.
This commit is contained in:
42
.github/workflows/release.yml
vendored
42
.github/workflows/release.yml
vendored
@@ -74,4 +74,46 @@ jobs:
|
||||
subject-digest: ${{ steps.push.outputs.digest }}
|
||||
push-to-registry: true
|
||||
|
||||
build_docs:
|
||||
name: Build docusaurus documentation
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 9
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
cache: pnpm
|
||||
cache-dependency-path: ./docs/pnpm-lock.yaml
|
||||
- name: Install dependencies
|
||||
run: pnpm --prefix docs install
|
||||
- name: Build website
|
||||
run: pnpm --prefix docs run build
|
||||
- name: Upload Build Artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs/build
|
||||
|
||||
publish_docs:
|
||||
name: Publish docusaurus docs to GitHub pages
|
||||
needs: build_docs
|
||||
permissions:
|
||||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
||||
pages: write # to deploy to Pages
|
||||
id-token: write # to verify the deployment originates from an appropriate source
|
||||
environment:
|
||||
# Deploy to the github-pages environment
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
|
||||
|
30
.github/workflows/test-deploy.yml
vendored
Normal file
30
.github/workflows/test-deploy.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Test deployment
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
# Review gh actions docs if you want to further define triggers, paths, etc
|
||||
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
|
||||
|
||||
jobs:
|
||||
test_docs_deploy:
|
||||
name: Test docusaurus documentation deployment
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 9
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
cache: pnpm
|
||||
cache-dependency-path: docs/pnpm-lock.yaml
|
||||
- name: Install dependencies
|
||||
run: pnpm --prefix docs install
|
||||
- name: Test build website
|
||||
run: pnpm --prefix docs run build
|
21
docs/.gitignore
vendored
Normal file
21
docs/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Dependencies
|
||||
/node_modules
|
||||
|
||||
# Production
|
||||
/build
|
||||
|
||||
# Generated files
|
||||
.docusaurus
|
||||
.cache-loader
|
||||
.next
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
echovault.io
|
3
docs/babel.config.js
Normal file
3
docs/babel.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
|
||||
};
|
5
docs/blog/authors.yml
Normal file
5
docs/blog/authors.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
kelvinmwinuka:
|
||||
name: Kelvin Clement Mwinuka
|
||||
title: EchoVault Maintainer
|
||||
url: https://kelvinmwinuka.com
|
||||
image_url: https://github.com/kelvinmwinuka.png
|
199
docs/docs/acl.md
Normal file
199
docs/docs/acl.md
Normal file
@@ -0,0 +1,199 @@
|
||||
---
|
||||
sidebar_position: 7
|
||||
---
|
||||
|
||||
# Access Control List
|
||||
|
||||
Access Control Lists enable you to add a layer of security to the EchoVault server or cluster. You can create users with associated rules and require clients to authorize before executing commands on the server.
|
||||
|
||||
EchoVault creates a default user upon startup. You can see this user by executing the following command:
|
||||
|
||||
```
|
||||
> ACL LIST
|
||||
1) "default on +@all +all %RW~* +&*"
|
||||
```
|
||||
|
||||
The default user is enabled, and has access to all categories, commands, keys and pub/sub channels. Connections are associated with user by default.
|
||||
|
||||
You can configure the default user to require a passwords by using the following configuration options:
|
||||
|
||||
- `--require-pass` forces the EchoVault server to require a user to authenticate itself using a password and/or username.
|
||||
|
||||
- `--password` attaches the provided password to the default user.
|
||||
|
||||
## Authorization
|
||||
|
||||
The TCP client can authenticate itself using the `AUTH` command:
|
||||
|
||||
`AUTH <username> <password>` tries to authenticate the TCP connection with the provided username and password.
|
||||
|
||||
`AUTH <password>` tries to authenticate the TCP connection with the default user and the provided passsword.
|
||||
|
||||
Authorization is not supported in embedded mode. When an EchoVault instance is embedded, it autimatically has access to all the commands exposed by the API.
|
||||
|
||||
## Configuration files
|
||||
|
||||
You can configure ACL Rules by passing the path to the config file to the `--acl-config=<path/to/config/file>` flag. The configuration file can be either a YAML or JSON file.
|
||||
|
||||
### YAML Config example
|
||||
|
||||
```yaml
|
||||
- Username: "user1"
|
||||
Enabled: true
|
||||
NoPassword: false
|
||||
NoKeys: false
|
||||
Passwords:
|
||||
- PasswordType: "plaintext"
|
||||
PasswordValue: "password1"
|
||||
- PasswordType: "SHA256"
|
||||
PasswordValue: "6cf615d5bcaac778352a8f1f3360d23f02f34ec182e259897fd6ce485d7870d4"
|
||||
IncludedCategories: ["*"]
|
||||
ExcludedCategories: []
|
||||
IncludedReadKeys: ["*"]
|
||||
IncludedWriteKeys: ["*"]
|
||||
IncludedPubSubChannels: ["*"]
|
||||
ExcludedPubSubChannels: []
|
||||
|
||||
- Username: "user2"
|
||||
Enabled: true
|
||||
NoPassword: false
|
||||
NoKeys: false
|
||||
Passwords:
|
||||
- PasswordType: "plaintext"
|
||||
PasswordValue: "password4"
|
||||
- PasswordType: "SHA256"
|
||||
PasswordValue: "8b2c86ea9cf2ea4eb517fd1e06b74f399e7fec0fef92e3b482a6cf2e2b092023"
|
||||
IncludedCategories: ["hash", "set", "sortedset", "list", "generic"]
|
||||
ExcludedCategories: []
|
||||
IncludedReadKeys: ["*"]
|
||||
IncludedWriteKeys: ["*"]
|
||||
IncludedPubSubChannels: ["user:channel:*"]
|
||||
ExcludedPubSubChannels: ["admin:channel:*"]
|
||||
```
|
||||
|
||||
### JSON Config example
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"Username": "user1",
|
||||
"Enabled": true,
|
||||
"NoPassword": false,
|
||||
"NoKeys": false,
|
||||
"Passwords": [
|
||||
{
|
||||
"PasswordType": "plaintext",
|
||||
"PasswordValue": "password1"
|
||||
},
|
||||
{
|
||||
"PasswordType": "SHA256",
|
||||
"PasswordValue": "6cf615d5bcaac778352a8f1f3360d23f02f34ec182e259897fd6ce485d7870d4"
|
||||
}
|
||||
],
|
||||
"IncludedCategories": ["*"],
|
||||
"ExcludedCategories": [],
|
||||
"IncludedReadKeys": ["*"],
|
||||
"IncludedWriteKeys": ["*"],
|
||||
"IncludedPubSubChannels": ["*"],
|
||||
"ExcludedPubSubChannels": []
|
||||
},
|
||||
{
|
||||
"Username": "user2",
|
||||
"Enabled": true,
|
||||
"NoPassword": false,
|
||||
"NoKeys": false,
|
||||
"Passwords": [
|
||||
{
|
||||
"PasswordType": "plaintext",
|
||||
"PasswordValue": "password4"
|
||||
},
|
||||
{
|
||||
"PasswordType": "SHA256",
|
||||
"PasswordValue": "8b2c86ea9cf2ea4eb517fd1e06b74f399e7fec0fef92e3b482a6cf2e2b092023"
|
||||
}
|
||||
],
|
||||
"IncludedCategories": ["hash", "set", "sortedset", "list", "generic"],
|
||||
"ExcludedCategories": [],
|
||||
"IncludedReadKeys": ["*"],
|
||||
"IncludedWriteKeys": ["*"],
|
||||
"IncludedPubSubChannels": ["user:channel:*"],
|
||||
"ExcludedPubSubChannels": ["admin:channel:*"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## ACL rules
|
||||
|
||||
ACL rules allow you to add new user profiles and set fine-grained rules that determine what clients can do on the server.
|
||||
|
||||
The default user's rules are very permissive so if you want to restrict access, you will have to explicitly configure ACL rules. The default user can be configured too.
|
||||
|
||||
### Enable and disable users
|
||||
|
||||
- `on` - Enable this user. A TCP connection can authenticate as this user.
|
||||
- `off` - Disable this user. It's impossible to authenticate as thsi user.
|
||||
|
||||
### Allow and disallow categories
|
||||
|
||||
- `+@all` - Allow this user to access all categories (aliased by `allCategories` and `+@*`). This overrides all other category access rules.
|
||||
- `-@all` - Block this user from accessing any categories (aliased by `-@*`, and `nocommands`). This overrides all other category access rules.
|
||||
- `+@<category>` - Allow this user to access the specified category. If updating an existing user, then this category will be added to the list of categories they are allowed to access.
|
||||
- `-@<category>` - Block the user from accessing this specific category. If updating an existing user, then this category is removed from the list of categories the user is allowed to access.
|
||||
|
||||
If both `+@all` and `-@all` are specified, whichever one is specified last will take effect.
|
||||
|
||||
The `nocommands` flag will apply the `-@all` rule.
|
||||
|
||||
### Allow and disallow commands
|
||||
|
||||
- `+all` - Allow this user to execute all commands (aliased by `allCommands`). This overrides all other command access rules.
|
||||
- `-all` - Block this user from executing any commands. This overrides all other command access rules.
|
||||
- `+<command>` - Allow the user to access the specified command. In order to allow the user to access only a specific subcommand, you can use `+<command>|<subcommand>`.
|
||||
- `-<command>` - Block this user from executing any commands. In order to allow the user to access only a specific subscommand, you can user `-<command>|<subcommand>`.
|
||||
|
||||
If both `+all` and `-all` are specified, whichever one is specified last will take effect.
|
||||
|
||||
The `nocommands` flag will apply the `-all` rule.
|
||||
|
||||
### Allow and disallow access to keys
|
||||
|
||||
By default, EchoVault allows each user to read and write to all keys. If you'd like to control what keys users have access to and what they can do with those keys, you can make use of the following options:
|
||||
|
||||
- `%RW~*` - Allow this user to read and write all keys on the EchoVault isntance (aliased by `allKeys`).
|
||||
- `%RW~<key>` - Allow this user to read and write to the specified key. This option accepts a glob pattern for the key which allows you to restrict certain key patterns.
|
||||
- `%W~*` - Allow the user to write to all keys.
|
||||
- `%W~<key>` - Block the user from writing to any keys except the one specified. A glob pattern can be used in place of the key.
|
||||
- `%R~*` - Allow the user to read from all the keys.
|
||||
- `%R~<key>` - Block the user from reading any keys except the one specified. A glob pattern can be used in place of the key.
|
||||
|
||||
### Allow and disallow Pub/Sub channels
|
||||
|
||||
- `+&*` - Allow this user to access all pub/sub channels (aliased by `allChannels`).
|
||||
- `-&*` - Block this user from accessing any of the pub/sub channels.
|
||||
- `+&<channel>` - Allow this user to access the specied channel. This rule accepts a glob pattern (e.g. "channel\*").
|
||||
- `-&<channel>` - Block this user from accessing the specied channel. This rule accepts a glob pattern (e.g. "channel\*").
|
||||
|
||||
If both `+&*` and `-&*` are specified, the one specified last will take effect.
|
||||
|
||||
### Add and remove passwords
|
||||
|
||||
By default users have no password and require no password to authenticate against them except when the `--require-pass` configuration is `true`. You can add and remove passwords associated with a user using the following options:
|
||||
|
||||
- `><password>` - Adds the plaintext password to the list of passwords associated with the user.
|
||||
- `<<password>` - Removes the plaintext password from the list of passwords associated with the user.
|
||||
- `#<hash>` - Adds the hash to the list of passwords associated with the user. The hash must be a SHA256 hash. When the user is being authenticated, they provide a plaintext passwords and the passwords will be compared with the user's plaintext passwords. If no match is found, the password's SHA256 hash is compared with the list of password hashes associated with the user.
|
||||
- `!<hash>` - Removes the SHA256 hash from the list of passwords hashes associated with the user.
|
||||
|
||||
### Reset the user
|
||||
|
||||
You can pass certain flags to make sweeping updates to a user's ACL rules. These flags often reset the granular rules specified above.
|
||||
|
||||
- `nopass` - Deletes all the user's associated passwords. Future TCP connections will not need to provide a password to authenticate against this user.
|
||||
- `resetpass` - Deletes all the user's associated passwords, but does not set the `nopass` flag to true.
|
||||
- `nocommands` - Blocks the user from executing any commands.
|
||||
- `resetkeys` - Blocks the user from accesssing any keys for both reads and writes (aliased by `nokeys`).
|
||||
- `resetchannels` - Allows the user to access all pub/sub channels.
|
||||
|
||||
## Examples
|
||||
|
||||
For examples on how to create and update ACL users and their rules, checkout out the `ACL SETUSER` command documentation.
|
11
docs/docs/architecture/index.md
Normal file
11
docs/docs/architecture/index.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
# Architecture
|
||||
|
||||
EchoVault can be run in the following modes:
|
||||
|
||||
- Standalone mode - Where only one instance runs in isolation.
|
||||
- Replication cluster - Strongly consistent RAFT cluster.
|
||||
- Sharding - To be implemented.
|
59
docs/docs/commands/acl/acl_cat.mdx
Normal file
59
docs/docs/commands/acl/acl_cat.mdx
Normal file
@@ -0,0 +1,59 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL CAT
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL CAT [category]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Lists all the categories. If the optional category is provided, lists all the commands in the category.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
List all categories:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
categories, err := vault.ACLCat()
|
||||
```
|
||||
|
||||
List all commands/subcommands in pubsub module:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
commands, err := vault.ACLCat("pubsub")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
List all categories:
|
||||
```
|
||||
> ACL CAT
|
||||
```
|
||||
|
||||
List all commands/subcommands in pubsub module:
|
||||
```
|
||||
> ACL CAT pubsub
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/acl/acl_deluser.mdx
Normal file
47
docs/docs/commands/acl/acl_deluser.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL DELUSER
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL DELUSER username [username ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Deletes users and terminates their connections. This command cannot delete the default user.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Delete users:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.ACLDelUser("username1", "username2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Delete users:
|
||||
```
|
||||
> ACL DELUSER username1 username2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
77
docs/docs/commands/acl/acl_getuser.mdx
Normal file
77
docs/docs/commands/acl/acl_getuser.mdx
Normal file
@@ -0,0 +1,77 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL GETUSER
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL GETUSER username
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
List the ACL rules of a user.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve user:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
rules, err := vault.ACLGetUser("username")
|
||||
```
|
||||
|
||||
Returns a map[string][]string map where each key is the rule category and each value is a string slice of relevant values.
|
||||
The map returned has the following structure:
|
||||
|
||||
- "username" - string slice containing the user's username.
|
||||
- "flags" - string slices containing the following values: "on" if the user is enabled, otherwise "off",
|
||||
- "nokeys" if the user is not allowed to access any keys (and NoKeys is true),
|
||||
- "nopass" if the user has no passwords (and NoPass is true).
|
||||
- "categories" - string slice af ACL command categories associated with the user.
|
||||
If the user is allowed to access all categories, it will contain "+@*".
|
||||
For each category the user is allowed to access, the slice will contain "+@\<category\>".
|
||||
If the user is not allowed to access any categories, it will contain "-@*".
|
||||
For each category the user is not allowed to access, the slice will contain "-@\<category\>".
|
||||
- "commands" - string slice af commands associated with the user.
|
||||
If the user is allowed to execute all commands, it will contain "+all".
|
||||
For each command the user is allowed to execute, the slice will contain "+\<command\>".
|
||||
If the user is not allowed to execute any commands, it will contain "-all".
|
||||
For each command the user is not allowed to execute, the slice will contain "-\<category\>".
|
||||
- "keys" - string slice af keys associated with the user.
|
||||
If the user is allowed read/write access all keys, the slice will contain "%RW~*".
|
||||
For each key glob pattern the user has read/write access to, the slice will contain "%RW~\<pattern\>".
|
||||
If the user is allowed read access to all keys, the slice will contain "%R~*".
|
||||
For each key glob pattern the user has read access to, the slice will contain "%R~\<pattern\>".
|
||||
If the user is allowed write access to all keys, the slice will contain "%W~*".
|
||||
For each key glob pattern the user has write access to, the slice will contain "%W~\<pattern\>".
|
||||
- "channels" - string slice af pubsub channels associated with the user.
|
||||
If the user is allowed to access all channels, the slice will contain "+&*".
|
||||
For each channel the user is allowed to access, the slice will contain "+&\<channel\>".
|
||||
If the user is not allowed to access any channels, the slice will contain "-&*".
|
||||
For each channel the user is not allowed to access, the slice will contain "-&\<channel\>".
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve user:
|
||||
```
|
||||
> ACL GETUSER username
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/acl/acl_list.mdx
Normal file
47
docs/docs/commands/acl/acl_list.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL LIST
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL LIST
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Dumps effective acl rules in ACL DSL format.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
List ACL rules:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
rules, err := vault.ACLList()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
List ACL rules:
|
||||
```
|
||||
> ACL LIST
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
58
docs/docs/commands/acl/acl_load.mdx
Normal file
58
docs/docs/commands/acl/acl_load.mdx
Normal file
@@ -0,0 +1,58 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL LOAD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL LOAD <MERGE | REPLACE>
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Reloads the rules from the configured ACL config file.
|
||||
When 'MERGE' is passed, users from config file who share a username with users in memory will be merged.
|
||||
When 'REPLACE' is passed, users from config file who share a username with users in memory will replace the user in memory.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Load ACL config:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Load config and merge with currently loaded ACL config
|
||||
ok, err := vault.ACLLoad(echovault.ACLLoadOptions{Merge: true})
|
||||
|
||||
// Load config and replace currently loaded ACL config
|
||||
ok, err := vault.ACLLoad(echovault.ACLLoadOptions{Replace: true})`
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Load ACL config file and merge it with currently loaded config:
|
||||
```
|
||||
> ACL LOAD MERGE
|
||||
```
|
||||
|
||||
Load ACL config file and replace the currently loaded config:
|
||||
```
|
||||
> ACL LOAD REPLACE
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
49
docs/docs/commands/acl/acl_save.mdx
Normal file
49
docs/docs/commands/acl/acl_save.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL SAVE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL SAVE
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Saves the effective ACL rules the configured ACL config file.
|
||||
The save command overwrites the current ACL config file entirely and using the current
|
||||
in-memory ACL configuration.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Save ACL rules:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := server.ACLSave()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Save ACL rules:
|
||||
```
|
||||
> ACL SAVE
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
123
docs/docs/commands/acl/acl_setuser.mdx
Normal file
123
docs/docs/commands/acl/acl_setuser.mdx
Normal file
@@ -0,0 +1,123 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL SETUSER
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL SAVE
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Configure a new or existing user.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Save user:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
user := echovault.User{}
|
||||
ok, err := server.ACLSetUser(user)
|
||||
```
|
||||
|
||||
The User struct takes the following shape:
|
||||
```go
|
||||
type User struct {
|
||||
// Username - string - the user's username.
|
||||
Username string
|
||||
|
||||
// Enabled - bool - whether the user should be enabled (i.e connections can authenticate with this user).
|
||||
Enabled bool
|
||||
|
||||
// NoPassword - bool - if true, this user can be authenticated against without a password.
|
||||
NoPassword bool
|
||||
|
||||
// NoKeys - bool - if true, this user will not be allowed to access any keys.
|
||||
NoKeys bool
|
||||
|
||||
// NoCommands - bool - if true, this user will not be allowed to execute any commands.
|
||||
NoCommands bool
|
||||
|
||||
// ResetPass - bool - if true, all the user's configured passwords are removed and NoPassword is set to false.
|
||||
ResetPass bool
|
||||
|
||||
// ResetKeys - bool - if true, the user's NoKeys flag is set to true and all their currently accessible keys are cleared.
|
||||
ResetKeys bool
|
||||
|
||||
// ResetChannels - bool - if true, the user will be allowed to access all PubSub channels.
|
||||
ResetChannels bool
|
||||
|
||||
// AddPlainPasswords - []string - the list of plaintext passwords to add to the user's passwords.
|
||||
AddPlainPasswords []string
|
||||
|
||||
// RemovePlainPasswords - []string - the list of plaintext passwords to remove from the user's passwords.
|
||||
RemovePlainPasswords []string
|
||||
|
||||
// AddHashPasswords - []string - the list of SHA256 password hashes to add to the user's passwords.
|
||||
AddHashPasswords []string
|
||||
|
||||
// RemoveHashPasswords - []string - the list of SHA256 password hashes to add to the user's passwords.
|
||||
RemoveHashPasswords []string
|
||||
|
||||
// IncludeCategories - []string - the list of ACL command categories to allow this user to access, default is all.
|
||||
IncludeCategories []string
|
||||
|
||||
// ExcludeCategories - []string - the list of ACL command categories to bar the user from accessing. The default is none.
|
||||
ExcludeCategories []string
|
||||
|
||||
// IncludeCommands - []string - the list of commands to allow the user to execute. The default is none. If you want to
|
||||
// specify a subcommand, use the format "command|subcommand".
|
||||
IncludeCommands []string
|
||||
|
||||
// ExcludeCommands - []string - the list of commands to bar the user from executing.
|
||||
// The default is none. If you want to specify a subcommand, use the format "command|subcommand".
|
||||
ExcludeCommands []string
|
||||
|
||||
// IncludeReadWriteKeys - []string - the list of keys the user is allowed read and write access to. The default is all.
|
||||
// This field accepts glob pattern strings.
|
||||
IncludeReadWriteKeys []string
|
||||
|
||||
// IncludeReadKeys - []string - the list of keys the user is allowed read access to. The default is all.
|
||||
// This field accepts glob pattern strings.
|
||||
IncludeReadKeys []string
|
||||
|
||||
// IncludeWriteKeys - []string - the list of keys the user is allowed write access to. The default is all.
|
||||
// This field accepts glob pattern strings.
|
||||
IncludeWriteKeys []string
|
||||
|
||||
// IncludeChannels - []string - the list of PubSub channels the user is allowed to access ("Subscribe" and "Publish").
|
||||
// This field accepts glob pattern strings.
|
||||
IncludeChannels []string
|
||||
|
||||
// ExcludeChannels - []string - the list of PubSub channels the user cannot access ("Subscribe" and "Publish").
|
||||
// This field accepts glob pattern strings.
|
||||
ExcludeChannels []string
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Checkout the <a href="/docs/acl">Access Control List documentation</a> for the list of rules.
|
||||
```
|
||||
> ACL SETUSER username
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/acl/acl_users.mdx
Normal file
47
docs/docs/commands/acl/acl_users.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL USERS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL USERS
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Lists all usernames of the configured ACL users.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
List ACL usernames:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
users, err := vault.ACLUsers()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
List ACL usersnames:
|
||||
```
|
||||
> ACL USERS
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
38
docs/docs/commands/acl/acl_whoami.mdx
Normal file
38
docs/docs/commands/acl/acl_whoami.mdx
Normal file
@@ -0,0 +1,38 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# ACL WHOAMI
|
||||
|
||||
### Syntax
|
||||
```
|
||||
ACL WHOAMI
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">acl</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Returns the authenticated user of the current connection.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Not available in embedded mode.
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the username of the user associated with the current connection:
|
||||
```
|
||||
> ACL WHOAMI
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/acl/index.md
Normal file
1
docs/docs/commands/acl/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# ACL
|
46
docs/docs/commands/admin/command_count.mdx
Normal file
46
docs/docs/commands/admin/command_count.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# COMMAND COUNT
|
||||
|
||||
### Syntax
|
||||
```
|
||||
COMMAND COUNT
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Get the dumber of commands in the echovault instance.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get server command count:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
count, err := vault.CommandCount()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get server command count:
|
||||
```
|
||||
> COMMAND COUNT
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
94
docs/docs/commands/admin/command_list.mdx
Normal file
94
docs/docs/commands/admin/command_list.mdx
Normal file
@@ -0,0 +1,94 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# COMMAND LIST
|
||||
|
||||
### Syntax
|
||||
```
|
||||
COMMAND LIST [FILTERBY <ACLCAT category | PATTERN pattern | MODULE module>]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Get the list of command names. Allows for filtering by ACL category or glob pattern.
|
||||
|
||||
### Options
|
||||
|
||||
FILTERBY - An optional condition used to filter the response. ACLCAT filters by the provided acl
|
||||
category string. PATTERN filters the response by the provided glob pattern.
|
||||
MODULE filters the response by the provided EchoVault module.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get a list of all the loaded commands:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
commands, err := vault.CommandList(echovault.CommandListOptions{})
|
||||
```
|
||||
|
||||
Get a list of all commands with the \"fast\" ACL category:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
commands, err := vault.CommandList(echovault.CommandListOptions{ACLCAT: "fast"})
|
||||
```
|
||||
|
||||
Get a list of all commands which satisfy the \"z*\" glob pattern:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
commands, err := vault.CommandList(echovault.CommandListOptions{PATTERN: "z*"})
|
||||
```
|
||||
|
||||
Get a list of all the commands in the \"set\" module:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
commands, err := vault.CommandList(echovault.CommandListOptions{MODULE: "set"})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get a list of all the loaded commands:
|
||||
```
|
||||
> COMMAND LIST
|
||||
```
|
||||
|
||||
Get a list of all commands with the "fast" ACL category:
|
||||
```
|
||||
> COMMAND LIST FILTERBY ACLCAT fast
|
||||
```
|
||||
|
||||
Get a list of all commands which satisfy the "z*" glob pattern:
|
||||
```
|
||||
> COMMAND LIST FILTERBY PATTERN z*
|
||||
```
|
||||
|
||||
Get a list of all the commands in the "set" module:
|
||||
```
|
||||
> COMMAND LIST FILTERBY MODULE set
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
40
docs/docs/commands/admin/commands.mdx
Normal file
40
docs/docs/commands/admin/commands.mdx
Normal file
@@ -0,0 +1,40 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# COMMANDS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
COMMANDS
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Get a list of all the commands in available on the echovault with categories and descriptions.
|
||||
Sub-commmands are formated as "command|subcommand".
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Make use of the <a href="/docs/commands/admin/command_list">CommandList method</a>.
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get List of commands:
|
||||
```
|
||||
> COMMAND
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/admin/index.md
Normal file
1
docs/docs/commands/admin/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Admin
|
47
docs/docs/commands/admin/lastsave.mdx
Normal file
47
docs/docs/commands/admin/lastsave.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LASTSAVE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LASTSAVE
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Get unix timestamp for the latest snapshot in milliseconds.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get last snapshot timestamp:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
count, err := vault.LastSave()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get last snapshot timestamp:
|
||||
```
|
||||
> LASTSAVE
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/admin/module_list.mdx
Normal file
47
docs/docs/commands/admin/module_list.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# MODULE LIST
|
||||
|
||||
### Syntax
|
||||
```
|
||||
MODULE LIST
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
List all the modules that are currently loaded in the server.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
List all the modules that are currently loaded in the server:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
modules := server.ListModules()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
List all the modules that are currently loaded in the server:
|
||||
```
|
||||
> MODULE LIST
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
63
docs/docs/commands/admin/module_load.mdx
Normal file
63
docs/docs/commands/admin/module_load.mdx
Normal file
@@ -0,0 +1,63 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# MODULE LOAD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
MODULE LOAD path [arg [arg ...]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Load a module from a dynamic library at runtime.
|
||||
The path should be the full path to the module, including the .so filename. Any args will be be passed unmodified to the
|
||||
module's key extraction and handler functions.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Load a modules with no args:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := server.LoadModule("/path/to/module.so")
|
||||
```
|
||||
|
||||
Load a module with a few args:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := server.LoadModule("/path/to/module.so", "arg1", "arg2", "arg3")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Load a module with no args:
|
||||
```
|
||||
> MODULE LOAD path/to/module.so
|
||||
```
|
||||
|
||||
Load a module with a few args:
|
||||
```
|
||||
> MODULE LOAD path/to/module.so arg1 arg2 arg3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/admin/module_unload.mdx
Normal file
47
docs/docs/commands/admin/module_unload.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# MODULE UNLOAD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
MODULE UNLOAD name
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Unloads a module based on the its name as displayed by the MODULE LIST command.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Unload a module:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := server.UnloadModule("module-name")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Unload a module:
|
||||
```
|
||||
> MODULE UNLOAD module-name
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/admin/rewriteaof.mdx
Normal file
47
docs/docs/commands/admin/rewriteaof.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# REWRITEAOF
|
||||
|
||||
### Syntax
|
||||
```
|
||||
REWRITEAOF
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Trigger re-writing of append process.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Trigger re-writing of append process:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
count, err := vault.RewriteAOF()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Trigger re-writing of append process:
|
||||
```
|
||||
> REWRITEAOF
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/admin/save.mdx
Normal file
47
docs/docs/commands/admin/save.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SAVE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SAVE
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">admin</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">admin</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Trigger a snapshot save.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Trigger a snapshot save:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
count, err := vault.Save()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Trigger a snapshot save:
|
||||
```
|
||||
> SAVE
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
46
docs/docs/commands/connection/auth.mdx
Normal file
46
docs/docs/commands/connection/auth.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# AUTH
|
||||
|
||||
### Syntax
|
||||
```
|
||||
AUTH [username] password
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">connection</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Authenticates the connection. If the username is not provided, the connection will be authenticated against the
|
||||
default ACL user. Otherwise, it is authenticated against the ACL user with the provided username.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
```go
|
||||
// Not available in embedded mode.
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Authenticate against the default user:
|
||||
```
|
||||
> AUTH password
|
||||
```
|
||||
Authenticate against a specific user:
|
||||
```
|
||||
> AUTH username password
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
86
docs/docs/commands/connection/hello.mdx
Normal file
86
docs/docs/commands/connection/hello.mdx
Normal file
@@ -0,0 +1,86 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HELLO
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HELLO [protover [AUTH username password] [SETNAME clientname]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">connection</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Switch to a different protocol, optionally authenticating and setting the connection's name.
|
||||
This command returns a contextual client report.
|
||||
|
||||
### Options
|
||||
- `protover` - The protocol version to switch to. The default is 2.
|
||||
- `AUTH username password` - Authenticate with the server using the specified username and password.
|
||||
- `SETNAME clientname` - Set the connection's name to the specified clientname.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
When using the embedded API, there's no need to authenticate the API caller or set an alias for the caller.
|
||||
Therefore, only the set protocol functionality is available in embedded mode. You can set the protocol using
|
||||
the SetProtocol method:
|
||||
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := vault.SetProtocol(2)
|
||||
```
|
||||
|
||||
The method above changes the protocol to version 3. This is relevant when executing commands using the
|
||||
`ExecuteCommand` method. Since this methods returns a raw RESP response. It will not affect any other methods'
|
||||
return types as they return native go types.
|
||||
|
||||
`SetProtocol` return an error if the protocol version is not supported (i.e. not 2 or 3).
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Only fetch client report:
|
||||
```
|
||||
> HELLO
|
||||
```
|
||||
|
||||
Authenticate and set the connection's name:
|
||||
```
|
||||
> HELLO 2 AUTH myuser mypass SETNAME myclient
|
||||
```
|
||||
|
||||
Authenticate only:
|
||||
```
|
||||
> HELLO 2 AUTH myuser mypass
|
||||
```
|
||||
|
||||
Set the connection's name only:
|
||||
```
|
||||
> HELLO 2 SETNAME myclient
|
||||
```
|
||||
|
||||
Switch to protocol version 3:
|
||||
```
|
||||
> HELLO 3
|
||||
```
|
||||
|
||||
Authenticate and switch to protocol version 3:
|
||||
```
|
||||
> HELLO 3 AUTH myuser mypass
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/connection/index.md
Normal file
1
docs/docs/commands/connection/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Connection
|
46
docs/docs/commands/connection/ping.mdx
Normal file
46
docs/docs/commands/connection/ping.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PING
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PING [message]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">connection</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Ping the echovault server. If a message is provided, the message will be echoed back to the client.
|
||||
Otherwise, the server will return "PONG".
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
```go
|
||||
// Not available in embedded mode.
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Ping without message (returns PONG):
|
||||
```
|
||||
> PING
|
||||
```
|
||||
Ping with message (returns "Hello, world!"):
|
||||
```
|
||||
> PING "Hello, world!"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
50
docs/docs/commands/connection/select.mdx
Normal file
50
docs/docs/commands/connection/select.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SELECT
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SELECT index
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">connection</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Change the logical database that the current connection is operating from.
|
||||
If the database does not exist, it will be created.
|
||||
When this command is executed in a RAFT cluster, the database will be created in all the nodes of the cluster.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Select the database that the embedded instance is operating from:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := vault.SelectDB(2)
|
||||
```
|
||||
After successfully calling this method, all subsequent commands executed on that instance
|
||||
will be executed on the selected database. So you should to be careful when doing this in a multi-threaded environment.
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Select the database with index 1:
|
||||
```
|
||||
> SELECT 1
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
52
docs/docs/commands/connection/swapdb.mdx
Normal file
52
docs/docs/commands/connection/swapdb.mdx
Normal file
@@ -0,0 +1,52 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SWAPDB
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SWAPDB index1 index2
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">connection</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
This command swaps two databases,
|
||||
so that immediately all the clients connected to a given database will see the data of the other database,
|
||||
and the other way around. If either one of the databases does not exist, it will be created.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Swap the databases with indexes 1 and 2:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err := vault.SwapDBs(1, 2)
|
||||
```
|
||||
The method above only switches the databases for the currently active TCP connections.
|
||||
To switch the database for the embeded instance, use the `SelectDB` method.
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Swap the databases with indexes 1 and 2:
|
||||
```
|
||||
> SWAPDB 1 2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
50
docs/docs/commands/generic/decr.mdx
Normal file
50
docs/docs/commands/generic/decr.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# DECR
|
||||
|
||||
### Syntax
|
||||
```
|
||||
DECR key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Decrements the number stored at key by one.
|
||||
If the key does not exist, it is set to 0 before performing the operation.
|
||||
An error is returned if the key contains a value of the wrong type or contains a string that cannot be represented as integer.
|
||||
This operation is limited to 64 bit signed integers.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Decrement the value of the key `mykey`:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
value, err := vault.Decr("mykey")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Decrement the value of the key `mykey`:
|
||||
```
|
||||
> DECR mykey
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/generic/decrby.mdx
Normal file
48
docs/docs/commands/generic/decrby.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# DECRBY
|
||||
|
||||
### Syntax
|
||||
```
|
||||
DECRBY key decrement
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
The DECRBY command reduces the value stored at the specified key by the specified decrement.
|
||||
If the key does not exist, it is initialized with a value of 0 before performing the operation.
|
||||
If the key's value is not of the correct type or cannot be represented as an integer, an error is returned.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Decrement the value of the key `mykey` by 5:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
value, err := vault.DecrBy("mykey 5")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Decrement the value of the key `mykey` by 5:
|
||||
```
|
||||
> DECRBY mykey 5
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
61
docs/docs/commands/generic/del.mdx
Normal file
61
docs/docs/commands/generic/del.mdx
Normal file
@@ -0,0 +1,61 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# DEL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
DEL key [key ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Removes one or more keys from the store.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Delete a single key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
noOfDeletedKeys, err = vault.Del("key1")
|
||||
```
|
||||
|
||||
Delete multiple keys:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
noOfDeletedKeys, err = vault.Del("key1", "key2", "key3")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Delete a single key:
|
||||
```
|
||||
> DEL key
|
||||
```
|
||||
|
||||
Delete multiple keys:
|
||||
```
|
||||
> DEL key1 key2 key3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
96
docs/docs/commands/generic/expire.mdx
Normal file
96
docs/docs/commands/generic/expire.mdx
Normal file
@@ -0,0 +1,96 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# EXPIRE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
EXPIRE key seconds [NX | XX | GT | LT]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Expire the key in the specified number of seconds. This commands turns a key into a volatile one.
|
||||
|
||||
### Options
|
||||
|
||||
- `NX` - Only set the expiry time if the key has no associated expiry.
|
||||
- `XX` - Only set the expiry time if the key already has an expiry time.
|
||||
- `GT` - Only set the expiry time if the new expiry time is greater than the current one.
|
||||
- `LT` - Only set the expiry time if the new expiry time is less than the current one.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Add an expiration to a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Expire("key", 10, echovault.ExpireOptions{})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it does not have one already:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Expire("key", 10, echovault.ExpireOptions{NX: true})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it has one already:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Expire("key", 10, echovault.ExpireOptions{XX: true})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it already has one that is less than the current expiry:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Expire("key", 10, echovault.ExpireOptions{XX: true, LT: true})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Add an expiration to a key:
|
||||
```
|
||||
> EXPIRE key 10
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it does not have one already:
|
||||
```
|
||||
> EXPIRE key 10 NX
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it has one already:
|
||||
```
|
||||
> EXPIRE key 10 XX
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it already has one that is less than the current expiry:
|
||||
```
|
||||
> EXPIRE key 10 XX LT
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/generic/expiretime.mdx
Normal file
47
docs/docs/commands/generic/expiretime.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# EXPIRETIME
|
||||
|
||||
### Syntax
|
||||
```
|
||||
EXPIRETIME key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the absolute unix time in seconds when the key will expire.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the expiration time of a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
expireTime, err := vault.ExpireTime("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the expiration time of a key:
|
||||
```
|
||||
> EXPIRETIME key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/generic/flushall.mdx
Normal file
48
docs/docs/commands/generic/flushall.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# FLUSHALL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
FLUSHALL
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Delete all the keys in all the existing databases. This command is always synchronous.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
In order to delete all the keys in all the databases, you need to pass -1 to the `Flush` method:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.Flush(-1)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Flush all the databases:
|
||||
```
|
||||
> FLUSHALL
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/generic/flushdb.mdx
Normal file
48
docs/docs/commands/generic/flushdb.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# FLUSHDB
|
||||
|
||||
### Syntax
|
||||
```
|
||||
FLUSHDB
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">dangerous</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Delete all the keys in the currently selected database. This command is always synchronous.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
For the embedded instance, you need to pass the database index to the `Flush` method:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.Flush(0)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Flush the database that the current connection is operating from:
|
||||
```
|
||||
FLUSHDB
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/generic/get.mdx
Normal file
47
docs/docs/commands/generic/get.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# GET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
GET key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Get the value at the specified key.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the value at the specified key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
value, err := vault.Get("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the value at the specified key:
|
||||
```
|
||||
> GET key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/generic/incr.mdx
Normal file
48
docs/docs/commands/generic/incr.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# INCR
|
||||
|
||||
### Syntax
|
||||
```
|
||||
INCR key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation.
|
||||
An error is returned if the key contains a value of the wrong type or contains a string that cannot be represented as integer.
|
||||
This operation is limited to 64 bit signed integers.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Increment the value of the key `mykey`:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
value, err := vault.Incr("mykey")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Increment the value of the key `mykey`:
|
||||
```
|
||||
> INCR mykey
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
49
docs/docs/commands/generic/incrby.mdx
Normal file
49
docs/docs/commands/generic/incrby.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# INCRBY
|
||||
|
||||
### Syntax
|
||||
```
|
||||
INCRBY key increment
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Increments the number stored at key by increment. If the key does not exist, it is set to 0 before performing the operation.
|
||||
An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer.
|
||||
|
||||
### Options
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Increment the value of the key `mykey` by 5:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
value, err := vault.IncrBy("mykey", "5")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Increment the value of the key `mykey` by 5:
|
||||
```
|
||||
> INCRBY mykey 5
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/generic/index.md
Normal file
1
docs/docs/commands/generic/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Generic
|
47
docs/docs/commands/generic/mget.mdx
Normal file
47
docs/docs/commands/generic/mget.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# MGET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
MGET key [key ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Get multiple values from the specified keys.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the values at the specified keys:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
values, err := vault.MGet("key1", "key2", "key3")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the values at the specified keys:
|
||||
```
|
||||
> MGET key1 key2 key3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
46
docs/docs/commands/generic/mset.mdx
Normal file
46
docs/docs/commands/generic/mset.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# MSET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
MSET key value [key value ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">write</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Set or modify multiple key/value pairs at once.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Set multiple key/value pairs:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.MSet(map[string]string{"key1": "value1", "key2": "value2", "key3": "value3"})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Set multiple key/value pairs:
|
||||
```
|
||||
> MSET key1 value1 key2 value2 key3 value3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/generic/persist.mdx
Normal file
47
docs/docs/commands/generic/persist.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PERSIST
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PERSIST key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Removes the TTl associated with a key, turning it from a volatile key to a persistent key.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Remove the TTL associated with a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Persist("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Remove the TTL associated with a key:
|
||||
```
|
||||
> PERSIST key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
95
docs/docs/commands/generic/pexpire.mdx
Normal file
95
docs/docs/commands/generic/pexpire.mdx
Normal file
@@ -0,0 +1,95 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PEXPIRE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PEXPIRE key seconds [NX | XX | GT | LT]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Expire the key in the specified number of milliseconds. This commands turns a key into a volatile one.
|
||||
|
||||
## Options
|
||||
|
||||
- `NX` - Only set the expiry time if the key has no associated expiry.
|
||||
- `XX` - Only set the expiry time if the key already has an expiry time.
|
||||
- `GT` - Only set the expiry time if the new expiry time is greater than the current one.
|
||||
- `LT` - Only set the expiry time if the new expiry time is less than the current one.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Add an expiration to a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updated, err := vault.PExpire("key", 10000, echovault.PExpireOptions{})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it does not have one already:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updated, err := vault.PExpire("key", 10000, echovault.PExpireOptions{NX: true})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it has one already:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updated, err := vault.PExpire("key", 10000, echovault.PExpireOptions{XX: true})
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it already has one that is less than the current expiry:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updated, err := vault.PExpire("key", 10000, echovault.PExpireOptions{XX: true, LT: true})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Add an expiration to a key:
|
||||
```
|
||||
> PEXPIRE key 10000
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it does not have one already:
|
||||
```
|
||||
> PEXPIRE key 10000 NX
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it has one already:
|
||||
```
|
||||
> PEXPIRE key 10000 XX
|
||||
```
|
||||
|
||||
Add an expiration to a key only if it already has one that is less than the current expiry:
|
||||
```
|
||||
> PEXPIRE key 10000 XX LT
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
50
docs/docs/commands/generic/pexpiretime.mdx
Normal file
50
docs/docs/commands/generic/pexpiretime.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PEXPIRETIME
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PEXPIRETIME key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
|
||||
### Description
|
||||
Returns the absolute unix time in milliseconds when the key will expire.
|
||||
Returns -1 if the key exists but has no associated expiry time.
|
||||
Returns -2 if the key does not exist.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve the expiration time of a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pexpireTime, err := vault.PExpireTime("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve the expiration time of a key:
|
||||
```
|
||||
> PEXPIRETIME key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
49
docs/docs/commands/generic/pttl.mdx
Normal file
49
docs/docs/commands/generic/pttl.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PTTL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PTTL key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the remaining time to live for a key that has an expiry time in milliseconds.
|
||||
If the key exists but does not have an associated expiry time, -1 is returned.
|
||||
If the key does not exist, -2 is returned.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve the expiration time of a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ttl, err := vault.PTTL("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve the expiration time of a key:
|
||||
```
|
||||
> PTTL key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
46
docs/docs/commands/generic/rename.mdx
Normal file
46
docs/docs/commands/generic/rename.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# RENAME
|
||||
|
||||
### Syntax
|
||||
```
|
||||
RENAME key newkey
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Renames key to newkey. If newkey already exists, it is overwritten. If key does not exist, an error is returned.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Rename the key `mykey` to `newkey`:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = vault.Rename("mykey", "newkey")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Rename the key `mykey` to `newkey`:
|
||||
```
|
||||
> RENAME mykey newkey
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
98
docs/docs/commands/generic/set.mdx
Normal file
98
docs/docs/commands/generic/set.mdx
Normal file
@@ -0,0 +1,98 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SET key value [NX | XX] [GET] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Set the value of a key, considering the value's type. If the key already exists, it is overwritten.
|
||||
|
||||
### Options
|
||||
- `NX` - Only set if the key does not exist.
|
||||
- `XX` - Only set if the key exists.
|
||||
- `GET` - Return the old value stored at key, or nil if the value does not exist.
|
||||
- `EX` - Expire the key after the specified number of seconds (positive integer).
|
||||
- `PX` - Expire the key after the specified number of milliseconds (positive integer).
|
||||
- `EXAT` - Expire at the exact time in unix seconds (positive integer).
|
||||
- `PXAT` - Expire at the exat time in unix milliseconds (positive integer).
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Set a value at a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Set("name", "EchoVault", echovault.SetOptions{})
|
||||
```
|
||||
|
||||
Set a value only if the key does not exist:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Set("name", "EchoVault", echovault.SetOptions{NX: true})
|
||||
```
|
||||
|
||||
Set a value if key already exists and get the previous value:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
previousValue, err := vault.Set("name", "EchoVault", echovault.SetOptions{XX: true, GET: true})
|
||||
```
|
||||
|
||||
Set a value if the key already exists, return the previous value, and expire after 10 seconds:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
previousValue, err := vault.Set("name", "EchoVault", echovault.SetOptions{XX: true, GET: true, EX: 10})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Set a value at a key:
|
||||
```
|
||||
> SET name EchoVault
|
||||
```
|
||||
|
||||
Set a value only if the key does not exist:
|
||||
```
|
||||
> SET name EchoVault NX
|
||||
```
|
||||
|
||||
Set a value if key already exists and get the previous value:
|
||||
```
|
||||
> SET name EchoVault XX GET
|
||||
```
|
||||
|
||||
Set a value if the key already exists, return the previous value, and expire after 10 seconds:
|
||||
```
|
||||
> SET name EchoVault XX GET EX 10
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
49
docs/docs/commands/generic/ttl.mdx
Normal file
49
docs/docs/commands/generic/ttl.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# TTL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
TTL key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">generic</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">keyspace</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the remaining time to live for a key that has an expiry time in milliseconds.
|
||||
If the key exists but does not have an associated expiry time, -1 is returned.
|
||||
If the key does not exist, -2 is returned.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve the expiration time of a key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ttl, err := vault.TTL("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve the expiration time of a key:
|
||||
```
|
||||
> TTL key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/hash/hdel.mdx
Normal file
48
docs/docs/commands/hash/hdel.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HDEL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HDEL key field [field ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
|
||||
### Description
|
||||
Deletes the specified fields from the hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Delete fields from a hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
deletedCount, err := vault.HDel("key", "field1", "field2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Delete fields from a hash:
|
||||
```
|
||||
> HDEL key field1 field2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/hash/hexists.mdx
Normal file
48
docs/docs/commands/hash/hexists.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HEXISTS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HEXISTS key field
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
|
||||
### Description
|
||||
Returns if field is an existing field in the hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns if field exists in a hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exists, err := vault.HExists ("key", "field1")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns if field exists in a hash:
|
||||
```
|
||||
> HEXISTS key field1
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hget.mdx
Normal file
47
docs/docs/commands/hash/hget.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HGET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HGET key field [field ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Retrieve the value of each of the listed fields from the hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve values from a hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
values, err := vault.HGet("key", "field1", "field2", "field3")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve values from a hash:
|
||||
```
|
||||
> HGET key field1 field2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hgetall.mdx
Normal file
47
docs/docs/commands/hash/hgetall.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HGETALL
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HGETALL key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Get all fields and values of a hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get all fields and values of a hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
result, err := vault.HGetAll("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get all fields and values of a hash:
|
||||
```
|
||||
> HGETALL key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hincrby.mdx
Normal file
47
docs/docs/commands/hash/hincrby.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HINCRBY
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HINCRBY key field increment
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Increment the hash value by the integer increment.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Increment the hash value by the integer increment:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
newValue, err := vault.HIncrBy("key", "field", 7)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Increment the hash value by the integer increment:
|
||||
```
|
||||
> HINCRBY key field 7
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hincrbyfloat.mdx
Normal file
47
docs/docs/commands/hash/hincrbyfloat.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HINCRBYFLOAT
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HINCRBYFLOAT key field increment
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Increment the hash value by the float increment.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Increment the hash value by the float increment:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
newValue, err := vault.HIncrByFloat("key", "field", 7.75)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Increment the hash value by the float increment:
|
||||
```
|
||||
> HINCRBYFLOAT key field 7.75
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hkeys.mdx
Normal file
47
docs/docs/commands/hash/hkeys.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HKEYS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HKEYS key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns all the fields in a hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve all fields from a hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
keys, err := vault.HKeys("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve all fields from a hash:
|
||||
```
|
||||
> HKEYS key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hlen.mdx
Normal file
47
docs/docs/commands/hash/hlen.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HLEN
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HLEN key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the number of fields in the hash.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Retrieve the number of fields in the hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.HLen("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Retrieve the number of fields in the hash:
|
||||
```
|
||||
> HLEN key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
51
docs/docs/commands/hash/hrandfield.mdx
Normal file
51
docs/docs/commands/hash/hrandfield.mdx
Normal file
@@ -0,0 +1,51 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HRANDFIELD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HRANDFIELD key [count [WITHVALUES]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns one or more random fields from the hash.
|
||||
|
||||
## Options
|
||||
- `WITHVALUES` - When provided, the return value will contain the field and its value.
|
||||
Otherwise, only the field is returned.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns one or more random fields from the hash:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fields, err := vault.HRandField("key", echovault.HRandFieldOptions{})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns one or more random fields from the hash:
|
||||
```
|
||||
> HRANDFIELD key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/hash/hset.mdx
Normal file
48
docs/docs/commands/hash/hset.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HSET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HSET key field value [field value ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Update each field of the hash with the corresponding value.
|
||||
If the field does not exist, it is created.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Update each field of the hash with the corresponding value:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
noOfUpdatedFields, err := vault.HSet("key", map[string]string{"field1": "value1", "field2": "value2"})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Update each field of the hash with the corresponding value:
|
||||
```
|
||||
> HSET key field1 value1 field2 value2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hsetnx.mdx
Normal file
47
docs/docs/commands/hash/hsetnx.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HSETNX
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HSETNX key field value [field value ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Set hash field value only if the field does not exist.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Set hash field value:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
noOfUpdatedFields, err := vault.HSetNX("key", map[string]string{"field1": "value1", "field2": "value2"})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Set hash field value:
|
||||
```
|
||||
> HSETNX key field1 value1 field2 value2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/hash/hstrlen.mdx
Normal file
48
docs/docs/commands/hash/hstrlen.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HSTRLEN
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HSTRLEN key field [field ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Return the string length of the values stored at the specified fields.
|
||||
Returns 0 if the value does not exist.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Return the string length of the values stored at the specified fields:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
lengths, err := vault.HStrLen("key", "field1", "field2", "field3")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Return the string length of the values stored at the specified fields:
|
||||
```
|
||||
> HSTRLEN key field1 field2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/hash/hvals.mdx
Normal file
47
docs/docs/commands/hash/hvals.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# HVALS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
HVALS key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">hash</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">hash</span>
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns all the values of the hash at key.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns all the values of the hash at key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
values, err := vault.HVals("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns all the values of the hash at key:
|
||||
```
|
||||
> HVALS key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/hash/index.md
Normal file
1
docs/docs/commands/hash/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Hash
|
5
docs/docs/commands/index.md
Normal file
5
docs/docs/commands/index.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
---
|
||||
|
||||
# Commands
|
1
docs/docs/commands/list/index.md
Normal file
1
docs/docs/commands/list/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# List
|
47
docs/docs/commands/list/lindex.mdx
Normal file
47
docs/docs/commands/list/lindex.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LINDEX
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LINDEX key index
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the list element at the given index.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns the list element at the given index:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
element, err := vault.LIndex("key", 2)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns the list element at the given index:
|
||||
```
|
||||
> LINDEX key 2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/llen.mdx
Normal file
47
docs/docs/commands/list/llen.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LLEN
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LLEN key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the length of a list.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns the length of a list:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.LLen("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns the length of a list:
|
||||
```
|
||||
> LLEN key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
48
docs/docs/commands/list/lmove.mdx
Normal file
48
docs/docs/commands/list/lmove.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LMOVE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LMOVE source destination <LEFT | RIGHT> <LEFT | RIGHT>
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Move element from one list to the other specifying left/right for both lists.
|
||||
LEFT represents the start of a list. RIGHT represents the end of a list.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Move an element from the beginning of the source list to the end of the destination list:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.LMove("source", "destination", "LEFT", "RIGHT")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Move an element from the beginning of the source list to the end of the destination list:
|
||||
```
|
||||
> LMOVE source destination LEFT RIGHT
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lpop.mdx
Normal file
47
docs/docs/commands/list/lpop.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LPOP
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LPOP key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Removes and returns the first element of a list.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Removes and returns the first element of a list:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
element, err := vault.LPop("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Removes and returns the first element of a list:
|
||||
```
|
||||
> LPOP key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lpush.mdx
Normal file
47
docs/docs/commands/list/lpush.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LPUSH
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LPUSH key element [element ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Prepends one or more values to the beginning of a list, creates the list if it does not exist.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Prepends one or more values to the beginning of a list, creates the list if it does not exist:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.LPush("key", "element1", "element2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Prepends one or more values to the beginning of a list, creates the list if it does not exist:
|
||||
```
|
||||
> LPUSH key element1 element2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lpushx.mdx
Normal file
47
docs/docs/commands/list/lpushx.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LPUSHX
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LPUSHX key element [element ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Prepends a value to the beginning of a list only if the list exists.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Prepends a value to the beginning of a list only if the list exists:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.LPushX("key", "element1", "element2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Prepends a value to the beginning of a list only if the list exists:
|
||||
```
|
||||
> LPUSHX key element1 element2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lrange.mdx
Normal file
47
docs/docs/commands/list/lrange.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LRANGE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LRANGE key start end
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Return a range of elements between the given indices.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Return a range of elements between the given indices:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
list, err := vault.LRange("key", 2, 6)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Return a range of elements between the given indices:
|
||||
```
|
||||
> LRANGE key 2 6
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lrem.mdx
Normal file
47
docs/docs/commands/list/lrem.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LREM
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LREM key count element
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Remove `<count>` elements from list.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Remove 2 instances if "value1" from the list at key:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Lrem("key", 2, "value1")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Remove 2 instances if "value1" from the list at key:
|
||||
```
|
||||
> LREM key 2 value1
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/lset.mdx
Normal file
47
docs/docs/commands/list/lset.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LSET
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LSET key index element
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Sets the value of an element in a list by its index.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Sets the value of an element in a list by its index:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.LSet("key", 2, "element")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Sets the value of an element in a list by its index:
|
||||
```
|
||||
> LSET key 2 element
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/ltrim.mdx
Normal file
47
docs/docs/commands/list/ltrim.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# LTRIM
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LTRIM key start end
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Trims a list using the specified range.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Trims a list using the specified range:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.LTrim("key", 2, 6)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Trims a list using the specified range:
|
||||
```
|
||||
> LTRIM key 2 6
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/rpop.mdx
Normal file
47
docs/docs/commands/list/rpop.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# RPOP
|
||||
|
||||
### Syntax
|
||||
```
|
||||
LPOP key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Removes and returns the last element of a list.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Removes and returns the last element of a list:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
element, err := vault.RPop("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Removes and returns the last element of a list:
|
||||
```
|
||||
> RPOP key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/rpush.mdx
Normal file
47
docs/docs/commands/list/rpush.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# RPUSH
|
||||
|
||||
### Syntax
|
||||
```
|
||||
RPUSH key element [element ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Prepends one or more values to the end of a list, creates the list if it does not exist.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Prepends one or more values to the end of a list, creates the list if it does not exist:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.RPush("key", "element1", "element2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Prepends one or more values to the end of a list, creates the list if it does not exist:
|
||||
```
|
||||
> RPUSH key element1 element2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/list/rpushx.mdx
Normal file
47
docs/docs/commands/list/rpushx.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# RPUSHX
|
||||
|
||||
### Syntax
|
||||
```
|
||||
RPUSHX key element [element ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">list</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">list</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Appends a value to the end of a list only if the list exists.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Appends a value to the end of a list only if the list exists:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
length, err := vault.RPushX("key", "element1", "element2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Appends a value to the end of a list only if the list exists:
|
||||
```
|
||||
> RPUSHX key element1 element2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/pubsub/index.md
Normal file
1
docs/docs/commands/pubsub/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# PubSub
|
57
docs/docs/commands/pubsub/psubscribe.mdx
Normal file
57
docs/docs/commands/pubsub/psubscribe.mdx
Normal file
@@ -0,0 +1,57 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PSUBSCRIBE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PSUBSCRIBE pattern [pattern ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Subscribe to one or more patterns. This command accepts glob patterns.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
The Subscribe method returns a readMessage function.
|
||||
This method is lazy so it must be invoked each time the you want to read the next message from
|
||||
the pattern.
|
||||
When subscribing to an'N' number of patterns, the first N messages will be
|
||||
the subscription confimations.
|
||||
The readMessage functions returns a message object when called. The message
|
||||
object is a string slice with the following inforamtion:
|
||||
event type at index 0 (e.g. subscribe, message), pattern at index 1,
|
||||
message/subscription index at index 2.
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
readMessage := vault.PSubscribe("subscribe_tag_1", "pattern_[12]", "pattern_h[ae]llo") // Return lazy readMessage function
|
||||
for i := 0; i < 2; i++ {
|
||||
message := readMessage() // Call the readMessage function for each channel subscription.
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
```
|
||||
> PSUBSCRIBE pattern_[12] pattern_h[ae]llo
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
46
docs/docs/commands/pubsub/publish.mdx
Normal file
46
docs/docs/commands/pubsub/publish.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PUBLISH
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PUBLISH channel message
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">fast</span>
|
||||
|
||||
### Description
|
||||
Publish a message to the specified channel.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Publish a message to the specified channel:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ok, err := vault.Publish("channel1", "Hello, world!")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Publish a message to the specified channel:
|
||||
```
|
||||
> PUBLISH channel1 "Hello, world!"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
50
docs/docs/commands/pubsub/pubsub_channels.mdx
Normal file
50
docs/docs/commands/pubsub/pubsub_channels.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PUBSUB CHANNELS
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PUBSUB CHANNELS [pattern]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns an array containing the list of channels that
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Returns an array containing the list of channels that
|
||||
match the given pattern. If no pattern is provided, all active channels are returned. Active channels are
|
||||
channels with 1 or more subscribers.
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
channels, err := vault.PubSubChannels("channel*")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Returns an array containing the list of channels that
|
||||
match the given pattern. If no pattern is provided, all active channels are returned. Active channels are
|
||||
channels with 1 or more subscribers.
|
||||
```
|
||||
> PUBSUB CHANNELS channel*
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
46
docs/docs/commands/pubsub/pubsub_numpat.mdx
Normal file
46
docs/docs/commands/pubsub/pubsub_numpat.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PUBSUB NUMPAT
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PUBSUB NUMPAT
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Return the number of patterns that are currently subscribed to by clients.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Return the number of patterns that are currently subscribed to by clients.
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
numOfPatterns, err := vault.PubSubNumPat()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Return the number of patterns that are currently subscribed to by clients.
|
||||
```
|
||||
> PUBSUB NUMPAT
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
49
docs/docs/commands/pubsub/pubsub_numsub.mdx
Normal file
49
docs/docs/commands/pubsub/pubsub_numsub.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PUBSUB NUMSUB
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PUBSUB NUMSUB [channel [channel ...]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Return an array of arrays containing the provided channel name and
|
||||
how many clients are currently subscribed to the channel.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Return an array of arrays containing the provided channel name and
|
||||
how many clients are currently subscribed to the channel.
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
stats, err := server.PubSubNumSub()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Return an array of arrays containing the provided channel name and
|
||||
how many clients are currently subscribed to the channel.
|
||||
```
|
||||
> PUBSUB NUMSUB channel1 channel2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
61
docs/docs/commands/pubsub/punsubscribe.mdx
Normal file
61
docs/docs/commands/pubsub/punsubscribe.mdx
Normal file
@@ -0,0 +1,61 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# PUNSUBSCRIBE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
PUNSUBSCRIBE [pattern [pattern ...]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Unsubscribe from a list of channels using patterns.
|
||||
If the pattern list is not provided, then the connection will be unsubscribed from all the patterns that
|
||||
it's currently subscribed to.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Unsubscribe from all patterns:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.PUnsubscribe()
|
||||
```
|
||||
Unsubscribe from specific patterns:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.PUnsubscribe("pattern_[12]", "pattern_h[ae]llo")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Unsubscribe from all patterns:
|
||||
```
|
||||
> PUNSUBSCRIBE
|
||||
```
|
||||
Unsubscribe from specific patterns:
|
||||
```
|
||||
> PUNSUBSCRIBE pattern_[12] pattern_h[ae]llo
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
57
docs/docs/commands/pubsub/subscribe.mdx
Normal file
57
docs/docs/commands/pubsub/subscribe.mdx
Normal file
@@ -0,0 +1,57 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SUBSCRIBE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SUBSCRIBE channel [channel ...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Subscribe to one or more channels.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
The Subscribe method returns a readMessage function.
|
||||
This method is lazy so it must be invoked each time the you want to read the next message from
|
||||
the channel.
|
||||
When subscribing to an'N' number of channels, the first N messages will be
|
||||
the subscription confimations.
|
||||
The readMessage functions returns a message object when called. The message
|
||||
object is a string slice with the following inforamtion:
|
||||
event type at index 0 (e.g. subscribe, message), channel name at index 1,
|
||||
message/subscription index at index 2.
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
readMessage := vault.Subscribe("subscribe_tag_1", "channel1", "channel2") // Return lazy readMessage function
|
||||
for i := 0; i < 2; i++ {
|
||||
message := readMessage() // Call the readMessage function for each channel subscription.
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
```
|
||||
> SUBSCRIBE channel1 channel2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
61
docs/docs/commands/pubsub/unsubscribe.mdx
Normal file
61
docs/docs/commands/pubsub/unsubscribe.mdx
Normal file
@@ -0,0 +1,61 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# UNSUBSCRIBE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
UNSUBSCRIBE [channel [channel ...]]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">pubsub</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">pubsub</span>
|
||||
<span className="acl-category">connection</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Unsubscribe from a list of channels.
|
||||
If the channel list is not provided, then the connection will be unsubscribed from all the channels that
|
||||
it's currently subscribed to.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Unsubscribe from all channels:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.Unsubscribe()
|
||||
```
|
||||
Unsubscribe from specific channels:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
vault.Unsubscribe("channel1", "channel2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Unsubscribe from all channels:
|
||||
```
|
||||
> UNSUBSCRIBE
|
||||
```
|
||||
Unsubscribe from specific channels:
|
||||
```
|
||||
> UNSUBSCRIBE channel1 channel2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
1
docs/docs/commands/set/index.md
Normal file
1
docs/docs/commands/set/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Set
|
47
docs/docs/commands/set/sadd.mdx
Normal file
47
docs/docs/commands/set/sadd.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SADD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SADD key member [member...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Add one or more members to the set. If the set does not exist, it's created.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Add members to the set:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SAdd("key", "member1", "member2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Add members to the set:
|
||||
```
|
||||
> SADD key member1 member2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/set/scard.mdx
Normal file
47
docs/docs/commands/set/scard.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SCARD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SCARD key
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">fast</span>
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">read</span>
|
||||
|
||||
### Description
|
||||
Returns the cardinality of the set.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the set's cardinality:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SCard("key")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the set's cardinality:
|
||||
```
|
||||
> SCARD key
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/set/sdiff.mdx
Normal file
47
docs/docs/commands/set/sdiff.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SDIFF
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SDIFF key [key...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns the difference between all the sets in the given keys.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the difference between 2 sets:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
elements, err := vault.SDiff("key1", "key2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the difference between 2 sets:
|
||||
```
|
||||
> SDIFF key1 key2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/set/sdiffstore.mdx
Normal file
47
docs/docs/commands/set/sdiffstore.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SDIFFSTORE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SDIFFSTORE destination key [key...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Works the same as SDIFF but stores the result at 'destination'.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Store the difference between 2 sets:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SDiffStore("destination", "key1", "key2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Store the difference between 2 sets:
|
||||
```
|
||||
> SDIFFSTORE destination key1 key2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/set/sinter.mdx
Normal file
47
docs/docs/commands/set/sinter.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SINTER
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SINTER key [key...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns the intersection of multiple sets.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the difference between 2 sets:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
elements, err := vault.SInter("key1", "key2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the difference between 2 sets:
|
||||
```
|
||||
> SINTER key1 key2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
65
docs/docs/commands/set/sintercard.mdx
Normal file
65
docs/docs/commands/set/sintercard.mdx
Normal file
@@ -0,0 +1,65 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SINTERCARD
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SINTERCARD key [key...] [LIMIT limit]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">read</span>
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">slow</span>
|
||||
|
||||
### Description
|
||||
Returns the cardinality of the intersection between multiple sets.
|
||||
|
||||
### Options
|
||||
- LIMIT - limit is an integer which determines the cardinality at which the intersection calculation
|
||||
is terminated.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the difference between 2 sets:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SInterCard([]string{"key1", "key2"}, 0)
|
||||
```
|
||||
|
||||
Get the intersection only upto an intersection cardinality of 5:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SInterCard([]string{"key1", "key2"}, 5)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the difference between 2 sets:
|
||||
```
|
||||
> SINTERCARD key1 key2
|
||||
```
|
||||
|
||||
Get the intersection only upto an intersection cardinality of 5:
|
||||
```
|
||||
> SINTERCARD key1 key2 LIMIT 5
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
47
docs/docs/commands/set/sinterstore.mdx
Normal file
47
docs/docs/commands/set/sinterstore.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# SINTERSTORE
|
||||
|
||||
### Syntax
|
||||
```
|
||||
SINTERSTORE destination key [key...]
|
||||
```
|
||||
|
||||
### Module
|
||||
<span className="acl-category">set</span>
|
||||
|
||||
### Categories
|
||||
<span className="acl-category">set</span>
|
||||
<span className="acl-category">slow</span>
|
||||
<span className="acl-category">write</span>
|
||||
|
||||
### Description
|
||||
Stores the intersection of multiple sets at the destination key.
|
||||
|
||||
### Examples
|
||||
|
||||
<Tabs
|
||||
defaultValue="go"
|
||||
values={[
|
||||
{ label: 'Go (Embedded)', value: 'go', },
|
||||
{ label: 'CLI', value: 'cli', },
|
||||
]}
|
||||
>
|
||||
<TabItem value="go">
|
||||
Get the difference between 2 sets:
|
||||
```go
|
||||
vault, err := echovault.NewEchoVault()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cardinality, err := vault.SInterStore("destination", "key1", "key2")
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="cli">
|
||||
Get the difference between 2 sets:
|
||||
```
|
||||
> SINTERSTORE destination key1 key2
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user