When 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 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 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 readingWe can use SQLite’s DATE()
function to return the first, second, third, fourth, etc instance of a given day within a given year.
We can use the same technique to return the first Monday of each month in the year.
It’s not limited to Monday though. The same techniques can be used on Tuesday, Wednesday, Thursday, Friday, etc.
Continue readingWhen setting an expiry for an existing key in Redis, we now have the option to set the expiry only if the key doesn’t already have an expiry. That’s because Redis 7.0.0 introduced some new options that allows us to do this and other things.
In this case, we can use the NX
option when setting the expiry to specify that the expiry should only be set if the key doesn’t already have an expiry. We can use this option on commands such as EXPIRE
, EXPIREAT
, PEXPIRE
, and PEXPIREAT
.
In PostgreSQL, we can use the +
operator to add one or more seconds to a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also add seconds to a date
value or a date
and time
combination.
A generated column is a database column whose value is an expression. Therefore, the value of the generated column is usually derived (for example, it could be derived from values in other columns).
Generated columns are also sometimes referred to as computed columns or virtual columns.
Creating a generated column in MariaDB is essentially the same as creating a normal column. The difference is that the definition of the generated column contains an expression that determines the column’s value.
Continue readingWhen using Redis, we often have many ways to do the same thing. One example of this is with deleting keys.
Below are four options for deleting keys in Redis.
Continue reading