In Redis, the SADD
command allows us to add members to a key. We can add multiple members if required.
A Redis set is an unordered collection of unique strings (members).
Continue readingIn Redis, the SADD
command allows us to add members to a key. We can add multiple members if required.
A Redis set is an unordered collection of unique strings (members).
Continue readingBelow are examples of using SQL to return the first day of the month across various DBMSs.
This could be the first day of the current month, or the first day of a month based on a given date.
Continue readingWhen working with Redis, we have a number of options for setting keys that store string values.
Here are six ways to set a string value in Redis.
Continue readingA Redis key can have an optional timeout, which makes the key expire after a certain amount of time, or at a certain time. We can use a couple of methods to remove any timeout associated with a key.
Here are two ways to remove a key’s expiry in Redis.
Continue readingWhen using the SET
command to set a key in Redis, we can use the GET
option to return its old value. This allows us to update the value of a key while returning the value that we’re replacing it with.
Note that this option was introduced in Redis 7.0.0, so if it doesn’t work, check your Redis version. If using an earlier version, try the GETSET
command instead (which is deprecated from Redis version 6.2.0).
In SQLite, we can use the DATE()
function to subtract one or more months from a date.
For datetime values, we can use the DATETIME()
function.
In Redis, we can use the OBECT IDLETIME
command to check how many seconds has passed since the last access to a given key.
In SQLite, the CASE
expression compares a list of conditions and returns one of multiple possible expressions.
The CASE
expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.
In Redis, we have several options for decrementing a key. By this, I mean, reducing the value of a key by one or more. For example, if we set a key to 15, we can decrement it by 1 to make 14. Or we can increment it by whatever amount we desire.
Continue readingIn Redis, the LTRIM
command allows us to trim a list to a specified number of elements. We specify the starting and ending index, which is used to trim the list to just that range.