Skip to content

SERedis Support KeyPrefix Feature #325

Closed
@vla

Description

@vla

Can RedisDBOptions add the KeyPrefix attribute to enable?

/// <summary>
/// Redis cache options.
/// </summary>
public class RedisDBOptions : BaseRedisOptions
{

.....

    /// <summary>
    /// Gets or sets the Redis database KeyPrefix will use.
    /// </summary>
    public string KeyPrefix { get; set; }
}

// RedisDatabaseProvider

/// <summary>
/// Gets the database connection.
/// </summary>
public IDatabase GetDatabase()
{
    try
    {

        var database = _connectionMultiplexer.Value.GetDatabase();
        if (!string.IsNullOrEmpty(_options.KeyPrefix))
            database = database.WithKeyPrefix(_options.KeyPrefix);
        return database;
    }
    catch (Exception)
    {
        _connectionMultiplexer = new Lazy<ConnectionMultiplexer>(CreateConnectionMultiplexer);
        throw;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions