kstyrc/embedded-redis

Is it possible to save to disk?

yadavan88 opened this issue · 2 comments

I am trying to use this embedded-redis as a temporary storage for a small device, if I there is no internet connectivity. When the connection is back, the data is uploaded to server. But with this, if the device is rebooted, the data will be lost. Is it possible to save the data to the disk and delete only on demand ?

It is possible. Take a look at the RedisServerBuilder#configFile() method. You can use it to start the server with a custom config file, which in turn lets you configure redis itself (including its persistence settings and all of that).

Thanks for the help. I did try that and it is working fine. Posting the sample here if anyone else is looking for the same.

RedisServer redisServer = RedisServer.builder()
                    .redisExecProvider(customProvider)
                    .port(6000)
                    .setting("daemonize no")
                    .setting("databases 5")
                    .setting("save 300 1")
                    .setting("dbfilename rbridgedump.rdb")
                    .setting("dir /home/Desktop")
                    .setting("maxheap 128M")
                    .build();