Skip to content
Young Yu edited this page May 26, 2024 · 6 revisions

Creates a new stash. Fails if the stash name is already taken, or if the stash name is too long. A stash's name is limited to 64 bytes in length (so 64 characters). Returns OK if successful.

CLI

Usage

create <name> [-off-heap <true/false>] [-max-keys <max_keys>] [-snapshots <true/false>]
  • name: The name of the stash to create. Required.
  • -off-heap: Whether to store values off-heap. Defaults to true. Optional.
  • -max-keys: The max number of keys allowed in the stash before eviction occurs. The max allowed value is the Long.MAX_VALUE or 2^32-1. Defaults to 1,000,000. Optional.
  • -snapshots: Whether to take periodic snapshots to disk. Defaults to false. Optional.

Example: no optional arguments

In this example, we create a stash named "people".

> create people
OK

Example: with all optional arguments

In this example, we create a stash named "pizzas" with snapshots enabled, storing values off-heap, and with a limit of 100 keys before eviction kicks in.

> create pizzas -snapshots true -off-heap false -max-keys 100
OK

TCP

For how to send commands directly through the TCP connection, see the protocol section.

Format

CREATE <name> <num_opt_args> [OFF_HEAP=<true/false>] [MAX_KEYS=<max_keys>] [SNAPSHOTS=<true/false>]
  • name: The name of the stash to create. Required.
  • num_opt_args: The number of optional arguments specified. Required.
  • OFF_HEAP: Whether to store values off-heap. Defaults to true. Optional.
  • MAX_KEYS: The max number of keys allowed in the stash before eviction occurs. The max allowed value is the Long.MAX_VALUE or 2^32-1 Defaults to 1,000,000. Optional.
  • SNAPSHOTS: Whether to take periodic snapshots to disk. Defaults to false. Optional.

Example: no optional arguments

CREATE pizzas 0 would be encoded as:

6\r\nCREATE6\r\npizzas1\r\n0

Example: with optional arguments

CREATE pizzas 1 OFF_HEAP=false would be encoded as:

6\r\nCREATE6\r\npizzas1\r\n114\r\nOFF_HEAP=false