In Redis, the SDIFFSTORE
command works just like the SDIFF
command, except that instead of returning the result, it stores it in the key that we specify. The destination key will then hold the members of the set resulting from the difference between the first set and all the successive sets.
5 Ways to See if a Table has a Generated Column in MySQL
MySQL supports generated columns. If you’re not sure whether a table has a generated column or not, you can check it using any of the following methods.
Continue readingRedis SDIFF Command Explained
In Redis, the SDIFF
command returns the members of the set resulting from the difference between the first set and all the successive sets. In other words, it returns all members of the first set that aren’t in any of the successive sets.
How to Return the Expiry Time as a Unix Timestamp in Redis
In Redis, we have several options for returning the expiry time of a key. One option from Redis 7.0.0 and above is to return it as a Unix timestamp.
When returning the expiry as a Unix timestamp, we can have it returned in seconds or milliseconds. To return it in seconds, we can use the EXPIRETIME
command. To return it in milliseconds, we can use the PEXPIRETIME
command.
2 Ways to Set a Redis Key Only When it Doesn’t Already Exist
In Redis, it’s possible to set a key only if it doesn’t already exist. As with most things, there’s more than one way to do this.
Continue readingHow to Set an Expiry Only When the New Expiry is Greater Than the Existing Expiry in Redis
Redis 7.0.0 introduced some potentially useful options for setting timeouts on keys. One of these is the GT
option, which allows us to set the expiry only if the new expiry is greater than the existing one.
The GT
option is available for commands such as EXPIRE
, EXPIREAT
, PEXPIRE
, and PEXPIREAT
.
Redis SCARD Command Explained
In Redis, the SCARD
command returns the number of members in the specified set. This is referred to as the cardinality of the set.
Redis SADD Command Explained
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 readingHow to Get the First Day of the Month in SQL
Below 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 reading6 Ways to Set a String in Redis
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 reading