Redis LCS Command Explained

In Redis, the LCS command implements the longest common subsequence algorithm.

The longest common subsequence algorithm finds the longest subsequence common to all sequences in a set of sequences. Note that this is different to the longest common string algorithm (also known as the longest common substring algorithm), which requires that matching characters in the string are contiguous. The longest common subsequence algorithm, on the other hand, doesn’t require matching characters to be contiguous.

The LCS command was introduced in Redis 7.0.0.

Continue reading

How NVL2() Works in MariaDB

In MariaDB, the NVL2() function allows us to replace a value with another value, the new value being determined by whether or not the initial value is null.

It’s similar to the NVL() function, except that NVL2() accepts three arguments instead of two. This allows us to specify a different value to return in the event the first argument is not null.

Continue reading

Redis SETNX Command Explained

The Redis SETNX command sets a key to a given value, but only if the key doesn’t already exist. If the key already holds a value, no operation is performed.

Note: The SET command can do the same thing, and it’s possible that the SETNX command may be deprecated at some point. Therefore, it’s probably a good idea to use SET instead of SETNX if possible.

Continue reading

SQL Server CASE Statement

The SQL Server CASE statement evaluates a list of conditions and returns one of multiple possible result expressions.

Although it’s commonly known as the “CASE statement”, the SQL Server documentation lists it as an expression. Plus it’s referred to as the “CASE expression” in the SQL standard. Some other DBMSs distinguish between the CASE statement and the CASE expression. Either way, here’s a quick rundown on how the “CASE statement” (or CASE expression) works in SQL Server.

Continue reading