2

i am new to the ServiceStack.Net Framework and I would like to understand the differences between the following methods:

public byte[][] Eval(string luaBody, int numberKeysInArgs, params byte[][] keys)
public RedisData EvalCommand(string luaBody, int numberKeysInArgs, params byte[][] keys)

Based on the source code the main difference is that the first call uses a SendExpectMultiData Request and the second command sends a RawCommand.

So when should I use the first method instead of the second method? What is the recommended usage of those methods?

wami
  • 435
  • 3
  • 10

1 Answers1

3

The IRedisNativeClient APIs are low-level and usually match 1:1 with the raw Redis Server API it's calling. The APIs on IRedisClient are higher-level and easier to use, e.g there are RedisDataExtensions which makes it easy to convert into Text and deserialize into complex type with .GetResult<T>() method.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • thank you for your fast answer, I know that this is a 1:1 mapping to the Redis Server API and thats exactly what i need for my ASP.net application. Nevertheless when I use the first command (byte[][] Eval) in my ASP.Net application i receive a exception "{Unknown reply on multi-request: 5817}" and with the other command it works as expected. Based on your documentation, I created the RedisClientManager as singleton and create and dispose my RedisNativeClient after every usage. So whats the difference between this to implementations? Are there things to reconsider? – wami Mar 22 '17 at 07:29
  • 1
    @wakm `Eval()` expects a strict [Multi Bulk Reply](https://redis.io/topics/protocol#resp-arrays) response whereas `EvalCommand` is able to parse the response into a flexible `RedisData` data structure. If you want to use a strict API you'll need to know what your Response is and [use the appropriate strict Eval API](https://github.com/ServiceStack/ServiceStack/blob/d39adc6d2699ef6cea4fdc5dfdb9a23851e341f0/src/ServiceStack.Interfaces/Redis/IRedisNativeClient.cs#L232-L238). – mythz Mar 22 '17 at 07:47