Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,155 of 9,155 pages
About the help in other languages
All help pages

Key-value imports: Redis, Valkey, Riak KV, RethinkDB and RavenDB

This page is for administrators who keep data in a key-value or document store and want it in Exponential as tables, and for developers who work on the readers. From Exponential 6.0.15 the kernel reads five such stores…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/features/6.0/key-value-imports.md

On this page

Key-value imports: Redis, Valkey, Riak KV, RethinkDB and RavenDB

This page is for administrators who keep data in a key-value or document store and want it in Exponential as tables, and for developers who work on the readers. From Exponential 6.0.15 the kernel reads five such stores and copies their records into the site's database or into any data table connection:

StoreCommandReached overLevel
Redis 6.2 to 7.4exp:redis:importthe Redis protocol (RESP2) in plain PHP, TCP, TLS or a Unix socketimport source
Valkey 7.2 to 8.1exp:valkey:importthe sameimport source; a cache through the extension sevenx_valkey_cache
Riak KV 2.2 and 3.0exp:riak:importRiak's HTTP API (PHP's curl extension)import source
RethinkDB 2.4exp:rethinkdb:importRethinkDB's driver protocol (V1_0, JSON, SCRAM-SHA-256) in plain PHPimport source
RavenDB 6.0 to 6.2exp:ravendb:importRavenDB's HTTP API (curl), a client certificate for a secured serverimport source

What none of them is. None is a site database and none is a database of data tables: they have no SQL, no joins and no schema the kernel could keep its tables in. They are import sources. A data table connection of one of these engines (Engine=redis ...) does not open a database; it names the store, so an import can say --source=<identifier> instead of repeating the server, the password and the TLS files (Setup > Data tables lists them with "an import source, read by exp:redis:import").

Caches. Redis and Valkey already serve Exponential as caches through the extension sevenx_valkey_cache; that is their cache role and it is unchanged. Riak KV, RethinkDB and RavenDB get no cache role: a cache backend wants a key expiry and microsecond reads on one round trip, which Riak (no expiry per key on the default backend), RethinkDB (document writes with durability) and RavenDB (documents with indexes) do not give cleanly.

Contents

  1. Requirements
  2. How records become tables
  3. Running an import
  4. A connection as the source
  5. Each store
  6. How it is built
  7. Tests

Requirements

WhatFor
PHP 8.0 or laterevery reader
PHP's curl extensionRiak KV and RavenDB
PHP's openssl extensionTLS to Redis, Valkey or RethinkDB; RavenDB's client certificates
A targetthe site's database, or a data table connection with write access

No library and no extension of a store is needed: the Redis protocol and RethinkDB's driver protocol are spoken in plain PHP (expRedisClient, expRethinkDBClient), Riak and RavenDB over HTTP (expKeyValueHttp).

How records become tables

A store names groups of records; every group becomes a table:

StoreA groupA recordThe key column
Redis, Valkeythe first segment of a key (user:1001 -> user); --depth=2 takes two (shop:order:17 -> shop_order); a key without the separator goes to the table keysa keydoc_id, the key
Riak KVa bucket of the bucket typean objectdoc_id, the object's key
RethinkDBa tablea documentthe table's primary key (id, or the one it was made with)
RavenDBa collection (@hilo left out; @empty becomes empty)a documentdoc_id, the document id (orders/1-A)

The columns are the fields of a sample of the group's records (500 by default, --sample), in the order they are met: integers become integer or bigint, numbers double, booleans boolean (written 1 and 0), short text text(255), long text and nested objects or lists memo (nested values written as JSON). A record that is no document is one column, value.

What each kind of Redis key gives:

TypeRecord
hashits fields; a field holding an integer or a number is typed as one (Redis keeps only text)
stringa JSON object gives its fields; anything else is value
JSON (RedisJSON, valkey-json)the document's fields
list, set, sorted set, streamvalue, as JSON (a set sorted, a sorted set as member => score)

Binary data that is no UTF-8 is written as base64. A table name is the group in lower case letters, digits and _; two groups with the same name get _2, _3.

Running an import

Every command works the same way as exp:couchdb:import and exp:access:import, with the same engine behind it:

# what is there: the tables and their columns
./console exp:redis:import --server=10.0.0.7 --database=2 --list

# the plan: the tables it would make, nothing written
./console exp:redis:import --server=10.0.0.7 --pattern='user:*' --secret=env:REDIS_PASSWORD

# the import
./console exp:redis:import --server=10.0.0.7 --secret=env:REDIS_PASSWORD --prefix=kv_ --apply

# into a data table connection, replacing its rows, machine output
./console exp:rethinkdb:import --source=realtime --connection=archive --mode=replace --apply --format=json
OptionMeaning
--listthe tables and their columns, then stop
--applymake the tables and copy the rows; without it the command shows the plan only
--connectionthe target: site (the default) or a data table connection
--tablesonly these tables (a comma list)
--prefixin front of every table name (kv_)
--modecreate (new tables only), append, replace (delete the rows first)
--samplethe records the columns are inferred from
--formattext or json
--sourcea connection naming the store, or --server, --port, --database, --user, --secret

The password is never given on the command line: --secret names a secret of Setup > Secrets or env:VARIABLE. Exit code 0 means done (or planned), 1 a table or row failed, 2 wrong options or no connection. A command never writes to the store it reads.

A connection as the source

A connection in settings/override/datatable.ini.append.php (or made in Setup > Data tables):

[Connection_sessions]
Name=Session store
Engine=valkey
Server=10.0.0.7
Port=6379
Database=0
Secret=env:VALKEY_PASSWORD
TLS=enabled
SSLCA=/etc/ssl/valkey-ca.pem

Database is the logical database number (Redis, Valkey), the bucket type (Riak, default) or the database (RethinkDB, RavenDB). TLS, SSLCA, VerifyTLS=disabled, and for RavenDB SSLCert and SSLKey (PEM files) are the TLS settings. Then:

./console exp:valkey:import --source=sessions --list

The engines are on the list of [ConnectionSettings] Engines[]; take one off to refuse its connections.

Each store

Redis and Valkey. The keys are walked with SCAN (never KEYS, which blocks the server), 500 at a time; the types and then the values of each batch are read in one pipeline each, so a key costs two commands on two round trips for 500 keys. A table's rows are scanned with its prefix as the pattern (user:*), so a large keyspace is walked once per table. --pattern narrows the keys (--pattern='shop:*'), --separator changes : (empty: every key in one table), --depth sets how many segments name the table. --user is an ACL user; with a password alone the command sends AUTH password. The server forms: host, host:port, redis://, rediss:// (TLS), valkey://, unix:///run/redis.sock. Keys that expire are read as they are at the moment of reading, and a key that disappears between the scan and the read is left out.

Riak KV. Every bucket of the bucket type is a table, its keys are listed and sorted, and every object read. A JSON object gives its fields, text is value, binary data value in base64. An object with siblings (allow_mult) is read as its first sibling. Listing buckets and keys walks every key of the cluster, which Riak advises against on a busy cluster: name the buckets (--buckets=users,orders) and run the import against a quiet node. Riak's own data types (counters, sets, maps of the datatypes endpoints) are not read.

RethinkDB. The handshake is V1_0 with SCRAM-SHA-256 (user admin with an empty password by default). Every table is a table with its primary key; the documents are read as one cursor, batch by batch. A time becomes Y-m-d H:i:s in UTC, binary data base64, a geometry its GeoJSON. TLS: --tls=enabled, --ca.

RavenDB. Every collection is a table, read page by page (1,024 documents a request) in the collection's order; the document id is doc_id and @metadata is left out. An unsecured server answers over http; a secured one wants a client certificate with read access to the database: --cert=/etc/exp/raven.pem (and --cert-key when the key is in a file of its own).

How it is built

ClassFileRole
expKeyValueReaderkernel/classes/keyvalue/expkeyvaluereader.phpthe common reader: groups as tables, the sample, the rows, the connection of the options
expRedisClient, expRedisReaderkernel/classes/keyvalue/expredisclient.php, expredisreader.phpRESP2, pipelines, SCAN; Redis and Valkey
expKeyValueHttpkernel/classes/keyvalue/expkeyvaluehttp.phpthe curl client of Riak and RavenDB
expRiakReaderkernel/classes/keyvalue/expriakreader.phpbuckets, keys, objects, siblings
expRethinkDBClient, expRethinkDBReaderkernel/classes/keyvalue/exprethinkdbclient.php, exprethinkdbreader.phpthe driver protocol, SCRAM-SHA-256, ReQL terms, cursors
expRavenDBReaderkernel/classes/keyvalue/expravendbreader.phpcollections and their documents
the commandskernel/private/classes/commands/exp{redis,valkey,riak,rethinkdb,ravendb}import.phpoptions; the run is exp:couchbase:import's

The readers speak the vocabulary of expAccessReader, so the import engine expAccessImport (the one of exp:access:import, exp:couchdb:import and exp:cassandra:import) makes the tables in the target's dialect and copies the rows.

Tests

SuiteWhat
keyvalueDB-less: stand-ins of every store; names, documents, the Redis protocol and addresses, SCRAM-SHA-256 against the example of RFC 7677, every reader, an import into SQLite
keyvalue-liveagainst live servers: Redis, Valkey, Riak KV, RethinkDB and RavenDB in containers; each test writes its data, imports it into SQLite and reads the rows back
php vendor/bin/phpunit --testsuite keyvalue
EXP_TEST_REDIS_HOST=127.0.0.1 EXP_TEST_REDIS_PASSWORD=... EXP_TEST_VALKEY_HOST=127.0.0.1 EXP_TEST_VALKEY_PORT=6380 \
EXP_TEST_RIAK_HOST=127.0.0.1 EXP_TEST_RETHINKDB_HOST=127.0.0.1 EXP_TEST_RAVENDB_URL=http://127.0.0.1:8080 \
php vendor/bin/phpunit --testsuite keyvalue-live

The live tests empty the logical database 3 of the Redis and Valkey servers they are given (FLUSHDB) and make and drop their own databases in RethinkDB and RavenDB: run them against servers of their own, never a production store. The GitHub job keyvalue runs both suites on PHP 8.5 and 8.1.

Measured on 2026-11-28 against containers (podman) with PHP 8.5: Redis 7.4.12, Valkey 8.1.12, RethinkDB 2.4.4 and RavenDB 6.2.22 pass the live tests (each import read and wrote every record, 2,000 Redis keys over several SCAN steps, 1,500 RethinkDB documents as a cursor, 1,100 RavenDB documents page by page). Riak KV was not measured there: the basho/riak-kv image does not start under podman ("su: System error"); the GitHub job runs it under Docker. The import writes the column names in lower case and gives a reserved word an underscore (value becomes value_).

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x