In Redis, we can use the STRLEN command to get the length of a given string value, based on its key.
We can also use the HSTRLEN command to get the string length of a value stored in a hash.
Many SQL databases have a SUBSTR() or equivalent function that returns a substring from a specified string.
Redis has a SUBSTR command, but it was deprecated in Redis 2.0.0.
However, Redis also has the GETRANGE command, that basically does the same thing. Basically, anything that was possible with the Redis SUBSTR command, is now possible with the GETRANGE command.
And the GETRANGE command does basically the same thing that most of the SUBSTR() and SUBSTRING() functions do in the SQL world – gets a substring from a string.
The INCR command is commonly used in Redis to increment a value by one. And the INCRBY command can be used to increment a valued by a specified integer. But neither of those commands let us work with floating point numbers.
If we want to use floating point numbers, we can use the INCRBYFLOAT command.
The Redis CLI allows us to easily run a command multiple times. All we need to do is prefix the command with the number of times we want it to run.
In Redis, the GETRANGE command allows us to get part of a string at a given key, starting and ending at the specified offsets.
The GETRANGE command replaced the SUBSTR command, which basically does the same thing. The SUBSTR command is now considered deprecated (as of Redis 2.0.0).
In Redis, the SETRANGE command allows us to overwrite part of a string at a given key, starting at a specified offset. It overwrites the old value from the specified offset, for the entire length of the new value.
In Redis, the DECRBY command decrements the value of a key by the specified amount.
If the key doesn’t exist, DECRBY creates the key with a value of 0 and then decrements it by the specified amount.
An error occurs if the key contains a value of the wrong type or contains a string that cannot be represented as integer. DECRBY operations are limited to 64 bit signed integers.