Skip to content

Procedure management

Val edited this page Sep 4, 2016 · 5 revisions

Procedures are loaded in the configuration, and they are automatically deployed to Redis when connecting the first time. If the connection is lost, the Redis connection automatically re-check again if the scripts are deployed, and deploy them otherwise.

The loader accepts a TextReader that may contain one or many procedures.

Simple loading

var options = new RedisClientOptions();
options
  .Procedures
  .Load(new StringReader(@"
     proc Sum(a, b)
       return a + b
     endproc"));
var client = new RedisClient(new IPEndPoint(IPAddress.Loopback, 6379), options);

Bulk loading

Multiple procedures can be uploaded from the same TextReader.

var options = new RedisClientOptions();
using ( var reader = new StreamReader(filePath))
    options.Procedures.Load(reader);
var client = new RedisClient(new IPEndPoint(IPAddress.Loopback, 6379), options);

Example of multiple procedures in a file in SimpleQA.

Loading from embedded resources

It is possible to pass an assembly and load all the embedded resources with a particular extension as procedures.

var options = new RedisClientOptions();
options.Procedures.LoadFromAssembly(Assembly.GetExecutingAssembly(), ".rcproc");
var client = new RedisClient(new IPEndPoint(IPAddress.Loopback, 6379), options);
Clone this wiki locally