crystal-redis

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介:

A Redis client for the Crystal programming language.

Features

  • Performance (> 680,000 commands per second using pipeline on a MacBook Air with a single client thread)
  • Pipelining
  • Transactions
  • LUA Scripting
  • All string commands
  • All hash commands
  • All list commands
  • All set commands
  • All hyperloglog commands
  • All commands for bit operations
  • All sorted set commands
  • Publish/subscribe

Installation

Add it to your shard.yml:

dependencies:
  redis:
    github: stefanwille/crystal-redis
    version: ~> 1.9.0

and then install the library into your project:

$ crystal deps

Required Crystal Version

This library needs Crystal version >= 0.18.2

Usage

Require the package:

  require "redis"

then

  redis = Redis.new

Then you can call Redis commands on the redis object:

  redis.set("foo", "bar")
  redis.get("foo")

Examples

To get started, see the examples:

  • There is a separate git repository crystal-redis-examples with examples.
  • start with this basic example
  • look at the other examples
  • the spec contains even more usage examples

Documentation

  • API documentation - start reading it at the class Redis.
  • Redis commands documentation - the original Redis documentation is necessary, as the API documentation above is just a quick reference
  • Redis documentation page - general information about Redis and its concepts

Performance

I have benchmarked Crystal-Redis against several other client libraries in various programming languages in this blog article.

Here are some results:

  • Crystal: With this library I get > 680,000 commands per second using pipeline on a MacBook Air with a single client thread.

  • C: The equivalent program written in C with Hiredis gets me 340,000 commands per second.

  • Ruby: Ruby 2.2.1 with the redis-rb and Hiredis driver handles 150,000 commands per second.

Read more results for Go, Java, Node.js.

Status

I have exercised every API method in the spec and built some example programs. There is no production use yet.

I took great care to make this library very usable with respect to API, reliability and documentation.

Development

This project requires a locally running redis server running on port 6379 and with a unix socket located at /tmp/redis.sock. Then you can the specs via

$ crystal spec

See more information.

Questions, Bugs & Support

If you have questions or need help, please open a ticket in the GitHub issue tracker. This way others can benefit from the discussion.






本文作者:陈群
本文来自云栖社区合作伙伴rediscn,了解相关信息可以关注redis.cn网站。
相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
8月前
|
NoSQL Redis
M1 MacBook安装redis
M1 MacBook安装redis
317 0
|
NoSQL 数据可视化 Redis
【redis】2.redis可视化工具安装使用
redis可视化工具:Redis Desktop Manager 1.redis桌面管理工具【可视化工具】下载 下载地址:https://redisdesktop.com/download   2.
2207 0
|
11月前
|
NoSQL 数据可视化 Redis
Redis可视化管理工具:Another Redis DeskTop Manager
Redis可视化管理工具:Another Redis DeskTop Manager
1443 0
|
NoSQL 容灾 Redis
Redis(二十七)- Redis的主从复制说明
单机的Redis服务器既需要读有需要写,Redis服务器的压力会比较大。所以,在实际的开发中一般会采取读写分离的形式。主从复制就是读写分离的一种形式。主服务器(master)以写为主,从服务器(slave)以读为主,主机数据更新后根据配置和策略,自动同步到备份机的master/slaver 机制。
141 0
Redis(二十七)- Redis的主从复制说明
|
NoSQL Linux Redis
《Redis篇》Another Redis DeskTop Manager 超详细安装教程
《Redis篇》Another Redis DeskTop Manager 超详细安装教程
507 0
《Redis篇》Another Redis DeskTop Manager 超详细安装教程
|
网络安全 NoSQL Redis
StackExchange.Redis使用配置
转自:http://www.cnblogs.com/deosky/p/4848403.html Configurationredis有很多不同的方法来配置连接字符串 , StackExchange.Redis 提供了一个丰富的配置模型,当调用Connect 或者 ConnectAsync 时需要传入。
2094 0
|
NoSQL Linux Redis
Redis-GUI客户端工具Another Redis Desktop Manager介绍
Redis-GUI客户端工具Another Redis Desktop Manager介绍
Redis-GUI客户端工具Another Redis Desktop Manager介绍
|
NoSQL API C#