Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created May 28, 2020 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgaskins/bdeb21f8797cc42b7b577554feb47a50 to your computer and use it in GitHub Desktop.
Save jgaskins/bdeb21f8797cc42b7b577554feb47a50 to your computer and use it in GitHub Desktop.
Adding stream support to Crystal Redis
class Redis
module Commands
def xadd(stream, id, params : Hash)
params = params.each_with_object(Array(String).new(params.size * 2)) do |(key, value), array|
array << key << value.to_s
end
string_command(["XADD", stream, id] + params)
end
def xrange(stream, start, finish)
string_array_command(["XRANGE", stream, start, finish])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment