You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug .SetAddAsync does not correctly serializes and adds single string or string[] to redis cache. Single items are added with "quotes" around them and multiple items are added as a single string array item.
To Reproduce
Consider using StackExchange.Redis.Extensions version 8.0.3
public class RedisController : Controller
{
public IRedisClient _redisCacheClient { get; }
private string _version = "8.0.3";
public RedisController(IRedisClient redisCacheClient)
{
_redisCacheClient = redisCacheClient;
}
[HttpGet]
[Route("Single-IRedisCacheClient")]
public async Task<IActionResult> AddSingleToSet()
{
var db = _redisCacheClient.GetDefaultDatabase();
RedisKey key = $"{_version}-IRedisCacheClient-peopleSingle";
await db.SetAddAsync(key, "Alexis", CommandFlags.None);
return Ok();
}
[HttpGet]
[Route("Multiple-IRedisCacheClient")]
public async Task<IActionResult> AddMultipleToSet()
{
var db = _redisCacheClient.GetDefaultDatabase();
RedisKey key = $"{_version}-IRedisCacheClient-peopleMultiple";
string[] redisValue1 = new string[] { "Nika", "Allah", "Booka" }; //.Select(key => (RedisValue)key).ToArray();
var dd = await db.SetAddAsync(key, redisValue1, StackExchange.Redis.CommandFlags.None);
return Ok();
}
}
This is the output we get:
Expected behavior
Using StackExchange.Redis.Extensions version 5.5.0 with obsolete ICacheClient client :
public class RedisController : Controller
{
public ICacheClient _cacheClient { get; }
private string _version = "5.5.0";
public RedisController(ICacheClient cacheClient)
{
_cacheClient = cacheClient;
}
[HttpGet]
[Route("Single-ICacheClient")]
public async Task<IActionResult> AddSingleToSetIRedisCacheClient()
{
var db = _cacheClient.Database;
RedisKey key = $"{_version}-ICacheClient-peopleSingle";
await db.SetAddAsync(key, "Alexis", CommandFlags.None);
return Ok();
}
[HttpGet]
[Route("Multiple-ICacheClient")]
public async Task<IActionResult> AddMultipleToSetIRedisCacheClient()
{
var db = _cacheClient.Database;
RedisKey key = $"{_version}-ICacheClient-peopleMultiple";
RedisValue[] redisValue = new string[] { "Alexis", "Peter", "Irina" }.Select(key => (RedisValue)key).ToArray();
var dd = await db.SetAddAsync(key, redisValue, StackExchange.Redis.CommandFlags.None);
return Ok();
}
}
We get correct redis cache entries:
Desktop (please complete the following information):
OS: Windws 10
Runtime version [.NET Framework, .NET 6.0]
Version [e.g. 8.0.3]
The text was updated successfully, but these errors were encountered:
It doesn't matter, either system.text or newtonsoft, both serialize string as an object in quotes. There should be a separate method that takes a string and not serialize it. Also regarding string[], it doesn't work as well
Describe the bug
.SetAddAsync
does not correctly serializes and adds singlestring
orstring[]
to redis cache. Single items are added with "quotes" around them and multiple items are added as a singlestring
array item.To Reproduce
Consider using
StackExchange.Redis.Extensions
version 8.0.3This is the output we get:
Expected behavior
Using
StackExchange.Redis.Extensions
version 5.5.0 with obsoleteICacheClient
client :We get correct redis cache entries:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: