Create table
CREATE TABLE events_all_time (
id int(11) unsigned NOTNULL AUTO_INCREMENT, action varchar(255) NOTNULL, count int(11) NOTNULL DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY uniq_action (action));
Below is an example of an sql script that exports data for redis pipe to read
SELECT CONCAT(
"*4\r\n",
'$', LENGTH(redis_cmd), '\r\n',
redis_cmd, '\r\n',
'$', LENGTH(redis_key), '\r\n',
redis_key, '\r\n',
'$', LENGTH(hkey), '\r\n',
hkey, '\r\n',
'$', LENGTH(hval), '\r\n',
hval, '\r'
)
FROM (
SELECT
'HSET' as redis_cmd,
'events_all_time' AS redis_key,
action AS hkey,
count AS hval
FROM events_all_time
) AS t
How can I modify the SQL script to create a schema in Redis with searchable indexes for each column for Redis search?
Then use this command to import to redis using redis-cli pipe.
mysql stats_db --skip-column-names --raw < events_to_redis.sql | redis-cli --pipe