miniredis icon indicating copy to clipboard operation
miniredis copied to clipboard

I've encountered some issues while using it. Can you help me?

Open DarkiT opened this issue 1 year ago • 3 comments

Hello, my friend. Thank you for providing such an excellent extension library, but I've encountered some issues while using it. Can you help me?

I have some not-so-important data to store, but I don't want to add an additional RedisServer, so I used the library you developed. It works great most of the time, but I encountered a problem when I stopped the service and tried to export the data. For example, the code s.Dump() below doesn't have any data.

func main() {
    ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
    defer stop()

    s := miniredis.NewMiniRedis()
    s.DB(16)
    if err := s.StartAddr(":6379"); err != nil {
        return
    }
    slog.Info(s.Addr())

    <-ctx.Done()
    slog.Info("export", slog.String("db", s.Dump()))
    s.Close()
    slog.Info("stop server")
}

Based on the above requirements, I hope there is an import and export to file feature so that the data stored in the last session can be automatically restored when the service stops and resumes. It would be best if the exported files could be compressed to save hard drive space. Do you have any plans to add this feature?

DarkiT avatar Jul 26 '24 14:07 DarkiT

miniredis really isn't meant for anything real, it's really only for helping in tests. If you want Redis I recommend installing a real Redis, not this.

alicebob avatar Jul 26 '24 14:07 alicebob

miniredis really isn't meant for anything real, it's really only for helping in tests. If you want Redis I recommend installing a real Redis, not this.

However, I must say it works very stably and has done an excellent job completing my tasks. For me, it has replaced a real RedisServer in my scenario.

DarkiT avatar Jul 26 '24 15:07 DarkiT

Okay, but adding proper export/import is still out of scope, unfortunately.

alicebob avatar Jul 27 '24 08:07 alicebob