Is there an easy way to turn a MySQL table into a Redis equivalent? -
is there easy way turn mysql table redis equivalent?
i have myisam table in mysql used key-value store want "move" redis super fast. there easy way this?
thanks.
the easiest way dump of mysql table , parse relevant data entries redis commands.
for example, data dump produce following:
create table carousel( id int(11), path varchar(200), title varchar(200), comments varchar(200) ); insert carousel values (3,'7.jpg','inspirar','inspiration'); insert carousel values (4,'d.jpg','pilotar','pilotar'); insert carousel values (5,'8.jpg','sentir','sentir'); insert carousel values (6,'6.jpg','volar','volar'); first need decide on key structure want use in redis. 1 idea use table key , store ids of each row in set.
for each table need create key hold ids, lets call them idx:$table. using our example create idx:carousel.
as parse file, pull ids first column of values (in case) , store them in idx:carousel. store each insert hash. name key carousel:$id , use command hmset. first insert in example stored this:
hmset carousel:3 path '7.jpg' title 'inspirar' comments 'inspiration'
it sounds more complicated is, quite straightforward. if think little difficult willing write 1 you.
hope helps.
Comments
Post a Comment