sorted sets A Redis sorted set is a collection of unique strings (members) ordered by an associated score. When more than one string has the same score, the strings are ordered lexicographically.
LPUSH key value [value ...]
tr.redisClient.LPush(
ctx,
"queue:tasks:immediate",
serializedData,
).Err()
where “queue:tasks:immediate”, is key and serializedData, value
we pass ctx in order to keep the lifescyle over connection for this task
task are best when something is asap where task arrives and execution is asap
for ex
- Send email
- Resize image
- Generate PDF
- Push notification
redis.Z{
Score: float64(targetTime),
Member: serializedData,
}
score = when to run
Member: serialised data
why float 64 ?
the driver expects float 64 so we convert the target time which is int64 by float64(int64)
DIAGRAM EXPLAINING THE PROCESS WHERE ROUTETASK IS A FUNCTION TAKING PARAMETERS AS CTX ,ID , TASKTYPE,PAYLOAD,MAXTRIES
