A Redis client for the Crystal programming language.
Add it to your shard.yml
:
dependencies:
redis:
github: stefanwille/crystal-redis
and then install the library into your project:
$ shards install
On MacOS X you may get this error:
ld: library not found for -lssl (this usually means you need to install the development package for libssl)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
...
Or this warning:
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libssl' found
Package libcrypto was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcrypto.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcrypto' found
The problem is that Crystal can't find openssl, because it is not installed by default on MacOS X.
The fix:
$ brew install openssl
PKG_CONFIG_PATH
:$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
Note: Please write me if you know a better way!
This library needs Crystal version >= 0.34.0
I haven't tested older Crystal versions.
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")
Since version 2.0.0, a connection pool is built in. It is used implicitly through Redis::PooledClient
:
redis = Redis::PooledClient.new
10.times do |i|
spawn do
redis.set("foo#{i}", "bar")
redis.get("foo#{i}") # => "bar"
end
end
This redis
instance can be shared across fibers, and accepts the same Redis commands as the Redis
class.It automatically allocates and frees connections from/to the pool, per command.
To get started, see the examples:
Redis
.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.
I have exercised every API method in the spec and built some example programs. Some people report production usage.
I took great care to make this library very usable with respect to API, reliability and documentation.
This project requires a locally running redis server running on port 6379 and with a Unix socket located at /tmp/redis.sock. In Homebrew's default redis.config the Unix domain socket option is disabled. To enable, edit /usr/local/etc/redis.conf
or whatever your redis.conf
is and uncomment this line:
# unixsocket /tmp/redis.sock
so that it reads
unixsocket /tmp/redis.sock
Then you can run the specs via
$ crystal spec
Running the spec will delete database number 0!
If you have questions or need help, please open a ticket in the GitHub issue tracker. This way others can benefit from the discussion.
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 Script
redis和Elasticsearch比较 项目 Redis Elasticsearch 介绍 Redis是内存中的数据结构存储,用作数据库,缓存和消息代理 Elasticsearch是一个基于Apache Lucene的现代搜索和分析引擎 主数据库模型 键值存储 搜索引擎 DB-Engines排名 得分120.41总排名第9,key-value存储排名第7 得分120.00总排名第10,搜索引擎
源码包安装的方式我就不多说了,教程很多。下面主要说一下怎么通过 yum 来进行更方便快捷的安装 redis。 1、检查是否有 redis yum 源 yum install redis(一般都会失败的,因为官方的源很滞后) [root@master packages]# yum install redis Loaded plugins: fastestmirror Determining fast
Nosql:非关系型的数据库; 1、键值对存储; 2、nosql数据库是动态结构,可以很容易适应数据类型和结构的变化。 3、nosql数据库是横向扩展,可扩展性。 4、关系型数据库遵循acid原则,nosql在CAP(一致性、可用性、分区容错性)中任选两项。 CA 传统oracle,AP 大多数网站架构,CP Redis BASE是为了解决关系数据库强一致性引起的问题而引起的可用性降低而提出的解决
Crystal Reports(水晶报表)是一款商务智能(BI)软件,主要用于设计及产生报表。水晶报表是业内最专业、功能最强的报表系统,它除了强大的报表功能外,最大的优势是实现了与绝大多数流行开发工具的集成和接口。在VS.Net平台做过报表开发的程序员,一定都对水晶报表强大、高效、集成等特性留下了深刻印象。 除了开发新程序外,在工作中我们常需要接触到很多较早的软件系统报表功能升级的需求,如果能结合
crystal-mysql MySQL driver implement natively in Crystal, without relying on external libraries. Check crystal-db for general db driver documentation. crystal-mysql driver is registered under mysql://
crystal-pg A native, non-blocking Postgres driver for Crystal usage This driver now uses the crystal-db project. Documentation on connecting,querying, etc, can be found at: https://crystal-lang.org/do
crystal-nodejs Node.js engine for crystal-lang. JS code and npm module executes on crystal-nodejs, And don't need to install Node.js binary.Explain about architecture, Compiled as a shared object Node
Crystal Website Powered by Jekyll Development setup (via docker) Checkout the repository Run $ docker-compose up Open a browser in localhost:4000 The docker container will launch jekyll with --increme
crystal-fann Crystal bindings for the FANN C lib Installation Add this to your application's shard.yml: dependencies: crystal-fann: github: NeuraLegion/crystal-fann Usage Look at the spec for most