struct MiniRedis::Value

Overview

A Redis value. It's #raw value has a type according to Redis Protocol Specification:

# Redis type    | First byte | Crystal type |
# ------------- | ---------- | ------------ |
# Simple String | `+`        | `String`     |
# Integer       | `:`        | `Int64`      |
# Bulk String   | `$`        | `Bytes`      |
# Array         | `*`        | `Array`      |
response = redis.transaction do |tx|
  pp tx.send("SET foo bar") # => MiniRedis::Value(@raw="QUEUED")
end

response = String.new(response.raw.as(Array).first.raw.as(Bytes))
pp response # => "bar"

response = redis.send("GET foo")
response = String.new(response.raw.as(Bytes))
pp response # => "bar"

Reminder — do not try to directly print a MiniRedis#send response when in pipeline mode! See MiniRedis#pipeline docs.

Defined in:

mini_redis/value.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(raw : Int64 | String | Bytes | Nil | Array(Value)) #

[View source]

Instance Method Detail

def raw : Array(MiniRedis::Value) | Int64 | Slice(UInt8) | String | Nil #

[View source]