Skip to content

v4: add CachedLuaScript - #3364

Open
pairbit wants to merge 10 commits into
seredis:v4from
pairbit:v4
Open

pairbit wants to merge 10 commits into
seredis:v4from
pairbit:v4

Conversation

@pairbit

@pairbit pairbit commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Hi. I have a lot of ideas and requests for version 4.
I’ll start with the main one: creating a new class for caching Lua scripts.
Scripts can be cached in a static variable without the RespScriptCache service.
This is exactly how I store scripts in my projects.

var result = await context.Scripts.EvaluateCachedAsync(Scripts.Script1, ["key1"], [new RedisValue("val1")]);

static class Scripts
{
    public static readonly CachedLuaScript Script1 = new("redis.call('SET', KEYS[1], ARGV[1])");
}

I created another version of the methods that does not include SendWithPreambleAsync.
I understand that you are trying to avoid an exception during the initial startup, but it seems unnecessary to me.
Could you explain why such complexity is necessary, given that the script will be loaded via Eval during a cold start anyway?

var result = await context.Scripts.EvaluateCached2Async(Scripts.Script1, ["key1"], [new RedisValue("val1")]);

@pairbit pairbit changed the title add CachedLuaScript v4: add CachedLuaScript Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant