PilotFish Redis XL User Guide
Table of Contents
- Use With XSLT
- Supported Commands
- Quick Overview
- Issuing Redis Commands
- Listener and Transport Configuration
Redis XL is an XML evaluation and execution system for making complex command calls to a Redis system. It allows for running any number of command calls in sequence, passing data between them, and outputting the response from the response in an easy to parse Format.
Redis XL benefits from a powerful set of tools that can be used around the actual commands, such as flow control, iteration, conditional logic, exception handling, outputting data, etc. It also has the ability to simply and effectively express any Redis command call needed.
This document will explain how to use all of Redis XL’s features so that this tool can be used effectively within the PilotFish application.
Use With XSLT
In many cases, Redis XL will be generated using XSLT in the PilotFish Data Mapper. In many ways, Redis XL is very similar in concept to XSLT: a series of special XML elements that provide instructions to a Processor that evaluates them. Because of how XSLT can dynamically build an output Format based on the values in an input format, it is ideal to use the Data Mapper to generate Redis XL using the data coming in.
However, it is important to always be aware that Redis XL and XSLT are completely independent of each other. They are each evaluated separately, by totally separate components. The XSLT created by the Data Mapper is evaluated during the XSLT Transformation stage, whereas the Redis XL is evaluated by a subsequent stage, usually the PilotFish Redis XL Transport.
This means that any XSLT instruction elements will only be used for creating the Redis XL document, and will not be present when the Redis XL is being evaluated. A good example would be iteration. An <xsl:for-each /> element will be used by the XSLT Transformation to produce XML output during its iteration. A <http:Iterate /> (covered later in this document) element will achieve the same iteration, but it will run only later when the Redis XL is evaluated.
The simple rule of thumb is that anything with the XSLT namespace prefix will only be present for the XSLT Transformation, while anything with the Redis XL namespace prefix will only be evaluated later on.
Redis XL supports a large subset of the currently available Redis commands but doesn’t include those that would be too cumbersome to understand and work with or wouldn’t make logical sense within the scope of the Redis XL. BITOP is an example of a command that would be far too cumbersome to try and represent in an XML-based structure. Redis XL currently supports nearly all commands available for Strings, Sets, Hashes, and HyperLogLog, as well as the PUBLISH command for Pub/Sub functionality and key-related commands like EXISTS, KEYS, and FLUSHALL.
This is a quick overview of what a typical Redis XL document looks like and how the different pieces are assembled. Each piece will be explained in more detail later in this Guide.
Issuing Redis Commands
The main structure of the Redis XL format is centered around the call/response nature of Redis itself, where issuing a command is done in two XML parts: CommandCall and CommandResponse.
The CommandCall piece is what actually executes the desired command. Any parameters required for the command, like the key and value information for this SET command, are provided as attributes. In the event a command can take multiple keys or values, provide those in a comma-separated format like so:
The tooltip documentation in the mapper itself also describes the necessary format. The commands are broken down by general type, where the children of the CommandCall element are Strings, Sets, etc., and nested within each of those are the actual GET, SET… commands.
Once the command is executed, the actual response from the Redis server is handled in the CommandResponse element. In this example, we are using the ‘as’ attribute to set the response into the variable ‘values’, and then using Output to write the response into the actual result XML generated after execution. Since the GET command here retrieves the value at the specified key, the response here would be a simple ‘testValue’ string. Array return types will be in a [field1, field2, field3…] format, and any integer returns will simply be displayed and handled as strings.
Listener and Transport Configuration
The Redis XL Listener and Transport operate essentially the same, though the Listener runs a provided Redis XML file on a polling schedule and begins Transactions while the Transport typically ends a transaction by evaluating and running the Redis XML contained in the Transaction Data. Both modules take the same set of Redis-related configuration as well, shown in the screenshot below:
- Input File: This option is used more often on the Listener than Transport, but lets you supply the Redis XML file to be evaluated and run. Note that if you supply an input file on the Transport side then any XML contained in the Transaction Data will not be used.
- Validate XML: Select this option to pre-validate the incoming XML against the Redis XL schema. If it does not conform to the schema, an exception will be thrown and the transaction will stop.
- Cache Schema: Select this option to cache the validation schema. This is useful to reduce loading the validation schema between executions.
- Response Listener: This option, only available on the Transport, is used to designate a Listener to which the Redis XL response should be sent after execution. The listener to be selected must be of the Programmable Listener (Trigger) type.
- Redis Host: The URL of the Redis server to connect to.
- Redis Port: The port of the Redis server to connect to. The default value is 6379.
- Database Number: This is the number (between 0-15) of the Redis database to connect to. If unsure, just leave as the default 0.
- Password: This option corresponds to the AUTH command, and will be issued before any other Redis commands if needed. If the Redis server does not require AUTH, leave this field blank.
- Evaluation Logging: This option enables debug logging, which is useful to trace the Redis XL execution. Note that selecting this option will also print to the eiPlatform logs.
- Cache Type: If a cache type besides the default is desired, select it from the drop-down. If unsure, leave as the default cache setting.