Search code examples
redisbooksleeve

How to call BGSAVE from BookSleeve?


Anyone can tell me how to call command BGSAVE from BookSleeve to Redis?

I search a lot in BookSleeve available methods but not found any commands relative to SAVE or BGSAVE.

Thanks!


Solution

  • Yes, it would seem that I never got around to adding that; I don't think SHUTDOWN is there either. In both cases, I expect they simply weren't things that are commonly performed at the reqest if a client - but are usually either automated (persistence configuration), or instigated at the command line (manually or as part of a script) as part of routine maintenance operations.

    I can get it added for the next build (probably with the "connection has admin commands enabled" check).

    A truly hacky workaround for now (untested) would be:

    .Scripting.Eval(0, "return redis.call('bgsave')", null, null);
    

    (caveat: the above makes me shudder)

    But again: if your application is just performing routine work, I would probably recommend using automatic redis persistence settings. If your application is a monitoring / maintenance front end, then SAVE doesn't seem too inappropriate.

    but not found any commands relative to SAVE or BGSAVE.

    Actually, I would strongly advise avoiding SAVE on a production server, unless you know it is safely off to one side and not being used; BGSAVE is not so invasive.