Skip to main content

Crate kividb

Crate kividb 

Source
Expand description

The internals of the KiviDB server, a Redis-compatible in-memory database.

This crate is published so that cargo install kividb can build the kividb server. The server binary is not built from this library: src/main.rs declares its own modules and its own global allocator. The library is built from the same sources so the integration tests can use them; it is not a public API. It is not a client or an embeddable database, and any release may change or remove any of it. It sets a global allocator too, so a crate that depended on it would get that one. To talk to KiviDB from Rust, use a Redis client such as the redis crate.

Documentation for running the server: https://github.com/kividbio/kividb.

Modules§

acl
aof
client_registry
cluster
cmdstats
command_gate
commands
compaction
Active defrag (#113): moving string values off the slabs that deletes have left sparse, so that those slabs empty and their memory goes back to the kernel (see value_slab).
config
eviction
What happens when maxmemory is reached: Redis’s maxmemory-policy.
expiry
field_expiry
key_bytes
A key as bytes, in twenty-four bytes where it is held: what a key that is kept outside the keyspace is (store::Key), as the list of keys due to expire, the keys a snapshot gives a time to live, eviction’s choice.
key_moves
keyspace_events
keyspec
latency
lazyfree
Freeing in the background what takes long to free, as Redis’s lazyfree does: a large value UNLINK removes, the keyspace FLUSHALL ASYNC and FLUSHDB ASYNC remove, the libraries FUNCTION FLUSH ASYNC removes.
listen
The ports clients connect to, and CONFIG SET port and tls-port moving them (#24).
loglevel
The server log.
member_set
The members of a set (SADD): a hash table that can also hand out a member at random without looking at the others.
memory_use
How much memory the process has allocated: what maxmemory is measured against, and used_memory in INFO.
monitor
node_tls
pause
protected_mode
pubsub
Pub/Sub: the hub that routes a published message to its subscribers, and what a connection keeps while it is one.
redis_settings
replication
resp
script_clock
Logical clock frozen for the duration of a Lua script / FCALL (Redis execution unit). TTL math and TIME use the snapshot taken when script execution starts.
server
server_uring
shared_bytes
Bytes that are shared and never changed, behind one pointer: what a string key’s value is.
shutdown
slowlog
snapshot
stats
store
tag_locks
tracking
types
update_check
Asking GitHub, once at startup, whether there is a newer KiviDB release.
value_slab
Slabs of KiviDB’s own for small string values (#113).
vector
wait_table
watch
write_gate
write_order

Macros§

log_at
log_debug
Internals, for whoever is debugging KiviDB itself.
log_error
Something failed and the operator has to act: data not saved, a replica that cannot sync, a file that cannot be read.
log_fatal
The process cannot go on; the caller exits after this.
log_info
The server’s life story: startup, loading, saving, role changes, configuration changes, shutdown. The default level.
log_throttled
Log at $level at most once every $secs seconds from this call site, for errors that can repeat as fast as the work that hits them (a full disk fails every AOF write; a file-descriptor limit fails every accept).
log_verbose
Per-client events: connections, authentication failures, protocol errors. Useful when chasing a client problem; noisy otherwise.
log_warn
Something is wrong or about to be, but the server carries on.
read_lock
write_lock

Statics§

RUNTIME_MAXMEMORY

Functions§

run_for_test
Entry point for integration tests — starts a tokio server on the given config and blocks the calling thread. Meant to run inside a thread::spawn.