I'm using ServicesStack Redis 4.5.14 with redis for windows 3.0.
I store the data as typed class. So that I can easily use GetAll() to get everything I need.
But now I'm facing a big problem: when the data count is bigger than 1024*1024 , I get the following error:
---- ServiceStack.Redis.RedisResponseException:“Protocol error: invalid multibulk length” ------
It seems like a Redis exception, that I can't fix.
Could anyone tell me how to fix it ?
Thanks
This is a limitation in Redis itself which doesn’t allow a multi bulk arg larger than 1024*1024 in length, there’s no work around other than using a sizes smaller than this.
I wounder if there’s any way to “fix” this problem by rewritten the GetAll() function in service stack ? e.g : Set a limit for the returning data count, to make sure every arg is smaller than 1024 * 1024 ?
We don’t add runtime checks to duplicate server exceptions in the client, it will never be able to stay in sync with redis-server which can vary between different server versions.
But could you help me to write another GetAll() function, that can get every saved data without causing the exception in redis while the count is larger than 1024*1024 ?
public IList<T> GetAll<T>()
{
var typeIdsSetKy = this.GetTypeIdsSetKey<T>();
var allTypeIds = this.GetAllItemsFromSet(typeIdsSetKy);
var urnKeys = allTypeIds.Cast<object>().Map(UrnKey<T>);
return GetValues<T>(urnKeys);
}
So you could get all the keys:
var typeIdsSetKy = this.GetTypeIdsSetKey<T>();
var allTypeIds = this.GetAllItemsFromSet(typeIdsSetKy);
var urnKeys = allTypeIds.Cast<object>().Map(UrnKey<T>);
Then you can fetch them in smaller batches:
var values = GetValues<T>(batchOfKeys);
If the issue is because your key size is too big there’s no solution other than using smaller keys.