# Your first records

**Applies to:** the public baseline and newer development builds. Install `smkv` and `smkv-tools` first. Commands below use the loopback data port.

## Start one node

For a package installation, use the service configured in [installation](installation.html):

```sh
sudo systemctl start smkv
```

Alternatively, run a foreground evaluation process with a new directory:

```sh
smkv-server --data-dir ./smkv-demo --bind 127.0.0.1:7379
```

Use one approach at a time; two processes cannot share the same port or data directory. Keep the foreground terminal open and use another for the following commands.

## Write and read

```sh
smkv --addr 127.0.0.1:7379 --sync put greeting hello
smkv --addr 127.0.0.1:7379 get greeting
```

The read prints `hello` without a trailing newline. Keys and values passed through this CLI are UTF-8 arguments; use the SDK for arbitrary bytes. `--sync` requests local durable storage before acknowledgment. It does not wait for a replica.

## Expire a record

```sh
smkv --addr 127.0.0.1:7379 put session active --ttl-ms 1000
sleep 2
smkv --addr 127.0.0.1:7379 get session
echo $?
```

The expired read prints no value and returns exit code `2`. Omit TTL for no expiration. Expiration removes logical visibility; it does not immediately reclaim every byte on disk.

## Verify restart recovery

For the package service:

```sh
sudo systemctl restart smkv
smkv --addr 127.0.0.1:7379 get greeting
```

For the foreground process, press Ctrl-C and rerun the identical server command with the same directory. Wait for startup before reading. `greeting` should still be `hello`. Ctrl-C and SIGTERM drain accepted work and synchronize partitions. This orderly restart check does not prove resilience to every machine failure.

## Delete a record

```sh
smkv --addr 127.0.0.1:7379 --sync delete greeting
smkv --addr 127.0.0.1:7379 get greeting
echo $?
```

The read returns exit code `2`. Operational failures return `1`. Never interpret an empty value alone as a miss; empty values are valid.

## Choose write guarantees

Default writes can be lost after failure. `--sync` makes the affected local partition durable. Newer quorum-managed development clusters additionally support `--replica-ack` and `--durable-replica-ack`; the latter waits for both copies to sync. These flags do not create transactions or protect against losing both disks.

A timed-out mutation may already have completed. Resolve that uncertainty in the application instead of blindly replaying writes. Next, [configure storage budgets](configuration.html) or [use the Go SDK](go-client.html).
