External Redis global cache
Store and retrieve reusable data in external Redis servers by using IBM® App Connect Enterprise.
Overview
Redis is a key-value database service with optional durability, and it runs on Linux® platforms either on-premises or in containers. You can use one or more external Redis servers to store data that you want to reuse. For detailed information about Redis, see the Redis documentation.
Key and value encoding
Redis supports keys and values that are arbitrary binary strings. App Connect Enterprise (ACE) Global Cache allows the use of a wide range of Java™ objects for both keys and values. App Connect Enterprise uses a simple encoding scheme to convert between the Java objects that the Global Cache supports and byte strings that can be stored in Redis.
App Connect Enterprise encodes a null Java value as an empty string, otherwise the following encoding scheme is used where the data begins with an ASCII character to determine the type of the encoded data, followed by type-specific data.
Data type | ASCII identifier | Encoded format |
---|---|---|
Boolean values | z |
The data is either ASCII 1 (true) or 0 (false). |
Byte values | b |
The data is any single byte. |
Character values | c |
The data is a UTF-16LE code unit (a 16-bit little endian value). |
Short values | s |
The data is an unsigned 16-bit little endian integer. |
Integer values | i |
The data is an unsigned 32-bit little endian integer. |
Long values | l |
The data is an unsigned 64-bit little endian integer. |
Float values | f |
The data is a 32-bit little endian IEEE 754 floating point value. |
Double values | d |
The data is a 64-bit little endian IEEE 754 floating point value. |
String values | S |
The data is the UTF-8 encoded string data, with possibly embedded null bytes. |
Decimal values | D |
The data is a UTF-8 encoded string describing a decimal value with possible exponent, for
example, +2.718E-12 . |
Byte array values | B |
The data is an arbitrary sequence of possibly null bytes. |
Bit array values | Z |
The data is a sequence of ASCII 1 and 0 characters. |
Date values | C |
The data is an unsigned 32-bit little endian YEAR, followed by an unsigned 8-bit MONTH from 1 (January) to 12 (December), followed by an unsigned 8-bit DAY from 1 to 31. |
Time values | t |
The data is an unsigned 8-bit HOUR (0-24), an unsigned 8-bit MINUTE (0-60), an unsigned 8-bit SECONDS (0-60), an unsigned 32-bit little endian MICROSECONDS (0-1000000), and a 32-bit unsigned little endian TIMEZONE LENGTH. If the TIMEZONE LENGTH is nonzero, then the remaining data is a UTF-8 string describing the time zone of the time. If the TIMEZONE LENGTH is zero, then the "local time zone" is assumed. |
Timestamp values | T |
The data is an unsigned 32-bit little endian YEAR, followed by an unsigned 8-bit MONTH from 1 (January) to 12 (December), followed by an unsigned 8-bit DAY from 1 to 31, unsigned 8-bit HOUR (0-24), an unsigned 8-bit MINUTE (0-60), an unsigned 8-bit SECONDS (0-60), an unsigned 32-bit little endian MICROSECONDS (0-1000000), and a 32-bit unsigned little endian TIMEZONE LENGTH. If the TIMEZONE LENGTH is nonzero, then the remaining data is a UTF-8 string describing the time zone of the time. If the TIMEZONE LENGTH is zero, then the "local time zone" is assumed. |
Serializable Java values | J |
The data is a serialized Java object following the Java Object Serialization Specification. |
Keys are encoded similarly to values by using the method described in the table, except the map
name is prepended as a UTF-8 string (with ASCII :
sequences replaced by
\:
and ASCII \
sequences replaced by \\
) followed
by an ASCII :
character. For example, storing the key "foo"
with
the value "bar"
in a map with name MY\MAP:NAME
results in a Redis key MY\\MAP\:name:Sfoo
and Redis value Sbar
.
Redis commands
App Connect Enterprise has a one-to-one mapping between MbGlobalMap operations and the corresponding Redis commands. Ensure that the user credentials you use to connect to the Redis server are authorized to perform the appropriate operations and that the Redis server you are connecting to support the particular form of the commands that App Connect Enterprise uses.
- The external Redis server must comply with the Redis API at version Redis Open Source 6.2.0 or later.
- The server does not need to use Redis-branded software.
- When connecting, App Connect Enterprise issues an
AUTH [username] password
command if a username or password is set on the security identity. For more information, see https://redis.io/docs/latest/commands/auth/ - When connecting, App Connect Enterprise issues a
SELECT index
command if a nondefault database number is specified. For more information, see https://redis.io/docs/latest/commands/select/ - When connecting, App Connect Enterprise issues a
CLIENT SETNAME connection-name
command if a connection name is specified. For more information, see https://redis.io/docs/latest/commands/client-setname/ - When performing the
MbGlobalMap.containsKey()
operation, App Connect Enterprise issues anEXISTS key
command by using the key encoding scheme that is described previously. For more information, see https://redis.io/docs/latest/commands/exists/ - When performing the
MbGlobalMap.get()
operation, App Connect Enterprise issues aGET key
command by using the key encoding scheme that is described previously. For more information, see https://redis.io/docs/latest/commands/get/ - When performing the
MbGlobalMap.remove()
operation, App Connect Enterprise issues aGETDEL key
command by using the key encoding scheme that is described previously. For more information, see https://redis.io/docs/latest/commands/getdel/ - When performing the
MbGlobalMap.put()
operation, App Connect Enterprise issues aSET key value NX
command by using the key and value encoding scheme that is described previously. For more information, see https://redis.io/docs/latest/commands/set/ - When performing the
MbGlobalMap.update()
operation, App Connect Enterprise issues aSET key value XX
command by using the key and value encoding scheme that is described previously. For more information, see https://redis.io/docs/latest/commands/set/