Skip to content

Clarification on how to use Sentinel and Lua Scripts #609

@TomT15

Description

@TomT15

Describe the issue
I am trying to use Lua scripts with Sentinel.

Setup of Redis

public static IServiceCollection AddStackExchangeRedisExtensions(this IServiceCollection services, RedisConfiguration redisConfiguration)
        {
            redisConfiguration.ExcludeCommands = null;
            redisConfiguration.AllowAdmin = true;
            services.AddSingleton(redisConfiguration);
            services.AddSingleton<IRedisConnectionPoolManager, RedisConnectionPoolManager>();
            services.AddSingleton<ISerializer, NewtonsoftSerializer>();
            services.AddSingleton<IRedisClient, RedisClient>();

            services.AddSingleton<IConnectionMultiplexer>(sp =>
                sp.GetRequiredService<IRedisConnectionPoolManager>().GetConnection());
            // We use IRedisDatabase for its default serailization functionality. It's great for working with lists and unwrapping them from json objects. Otherwise we use IRedisDatabase.Database (basically raw access). 
            services.AddSingleton<IRedisDatabase>(sp =>
                sp.GetRequiredService<IRedisClient>().GetDefaultDatabase());

            return services;
        }

calling Lua Script

            RedisValue[]? incrementValue = (RedisValue[]?)await _redis.Database.ScriptEvaluateAsync(_luaScript, redisParams);

Error:
StackExchange.Redis.RedisCommandException: This operation has been disabled in the command-map and cannot be used: EVAL

To Reproduce
Steps to reproduce the behavior:
Just run it as listed above

Expected behavior
I expected that access to _redis.Database to call directly to redis master and execute the script

Screenshots / StackTrace
If applicable, add screenshots to help explain your problem.

Not applicable but can get

Desktop (please complete the following information):
container images

  • bitnamilegacy/redis:8.2.1-debian-12-r0
  • bitnamilegacy/redis-sentinel:8.2.1-debian-12-r0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions