String and Hash
Learn the basics of string and hash and how to execute their operations using the go-redis client.
String
A string is one of the simplest data types, which makes it a good starting point to learn Redis. Despite its simplicity, it’s quite versatile. It can be used to cache a simple value for a key or a complex result of a SQL query. In addition to this, it can also be used for bitwise operations and as atomic counters.
Note: By default, the maximum size of a Redis string value is 512 MB.
Let’s go over some of the common String operations.
Set
Apply Time-to-Live (TTL)
Incr
,IncrBy
SetArgs
GetRange
Set
We can set a key to a string value. In this example, the key foo
is set to the value bar
using the Set
method.
Get hands-on with 1400+ tech skills courses.