Valkey Key Naming Conventions: How to Name Your Keys
Valkey has no tables, so key names carry the structure. Use object:id:field, keep names readable but short, and find related keys with SCAN.
- Database
- Valkey
Valkey has no tables, so key names carry the structure. Use object:id:field, keep names readable but short, and find related keys with SCAN.
Check your Valkey version three ways: valkey-server --version, valkey-cli --version and the INFO server command.
FLUSHDB empties only the database you’re in, while FLUSHALL empties every database on the server. Here’s each one, with real output.
Switch between Valkey’s numbered databases with SELECT, and see from the valkey-cli prompt which one you’re using.
KEYS and SCAN both list keys in Valkey, but KEYS makes the server wait until it’s done. Here’s the difference, with the same keys listed both ways.
List every key in Valkey, or only the keys that match a pattern, with valkey-cli --scan, the safe way that never stalls the server.
Put the command after valkey-cli, and it runs once, prints the reply and exits, without opening the interactive prompt.
Connect valkey-cli to Valkey on your own computer, to a host and port, to a numbered database or with a valkey:// URI, and leave it again with exit.
Open valkey-cli and run your first Valkey commands: save a value with SET, read it with GET, check it with EXISTS and TYPE, list keys safely with SCAN and delete them with DEL.
On macOS, valkey-cli reports “setsockopt(TCP_NODELAY): Invalid argument” when Valkey isn’t running or is on another port. Here’s the check that shows it and the fix.