Project

valkey-rb

0.02
The project is in a healthy, maintained state
A Ruby client library for Valkey
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.17.0
~> 3.23, >= 3.23.4
 Project Readme

Valkey

A Ruby client library for Valkey built with Valkey Glide Core that tries to provide a drop in replacement for redis-rb.

Features

  • High Performance: Built on Valkey GLIDE Core (Rust-based) for optimal performance
  • OpenTelemetry Integration: Built-in distributed tracing support
  • Client Statistics: Real-time monitoring of connections and commands
  • Drop-in Replacement: Compatible with redis-rb API

Getting started

Install with:

$ gem install valkey

You can connect to Valkey by instantiating the Valkey class:

require "valkey"

valkey = Valkey.new

valkey.set("mykey", "hello world")
# => "OK"

valkey.get("mykey")
# => "hello world"

OpenTelemetry and Monitoring

The Valkey client includes built-in support for OpenTelemetry distributed tracing and client statistics monitoring.

OpenTelemetry Tracing

Enable automatic tracing of all Valkey operations:

require 'valkey'
require 'opentelemetry/sdk'

# Configure OpenTelemetry
OpenTelemetry::SDK.configure do |c|
  c.service_name = 'my-app'
end

# Create client with tracing enabled
client = Valkey.new(
  host: 'localhost',
  port: 6379,
  tracing: true
)

# All commands are automatically traced
client.set('key', 'value')
client.get('key')

Client Statistics

Monitor connection and command metrics in real-time:

client = Valkey.new

# Execute some operations
client.set('key1', 'value1')
client.get('key1')

# Get statistics
stats = client.get_statistics

puts "Active connections: #{stats[:connection_stats][:active_connections]}"
puts "Total commands: #{stats[:command_stats][:total_commands]}"
puts "Success rate: #{
  (stats[:command_stats][:successful_commands].to_f / 
   stats[:command_stats][:total_commands] * 100).round(2)
}%"

For detailed documentation, see OPENTELEMETRY_GUIDE.md and opentelemetry_example.rb.

Documentation

Checkout the implementation status of the Valkey commands.