<commit_before>[![Build Status](https://travis-ci.org/Asmod4n/mruby-hiredis.svg)](https://travis-ci.org/Asmod4n/mruby-hiredis)
# mruby-hiredis
mruby bindings for https://github.com/redis/hiredis

Examples
========

Connect to the default redis-server
```ruby
hiredis = Hiredis.new
```

Connect to a tcp redis-server
```ruby
hiredis = Hiredis.new("localhost", 6379) #if you leave the port out it defaults to 6379
```

Connect to a unix redis-server
```ruby
hiredis = Hiredis.new("/tmp/redis.sock", -1) #set port to -1 so it connects to a unix socket
```

All Redis Commands are mapped to Ruby Methods, this happens automatically when you connect the first time to a Server.
```ruby
hiredis["foo"] = "bar"
hiredis["foo"]
hiredis.incr("bar")
```

If you later on want to add more shortcut methods, because the first Server you connected to is of a lower version than the others, you can call
```ruby
Hiredis.create_shortcuts(hiredis)
```

Pipelining
```ruby
hiredis.queue(:set, "foo", "bar")
hiredis.queue(:get, "foo")
hiredis.reply<commit_msg>added link to redis commands<commit_after>[![Build Status](https://travis-ci.org/Asmod4n/mruby-hiredis.svg)](https://travis-ci.org/Asmod4n/mruby-hiredis)
# mruby-hiredis
mruby bindings for https://github.com/redis/hiredis

Examples
========

Connect to the default redis-server
```ruby
hiredis = Hiredis.new
```

Connect to a tcp redis-server
```ruby
hiredis = Hiredis.new("localhost", 6379) #if you leave the port out it defaults to 6379
```

Connect to a unix redis-server
```ruby
hiredis = Hiredis.new("/tmp/redis.sock", -1) #set port to -1 so it connects to a unix socket
```

All [Redis Commands](http://redis.io/commands) are mapped to Ruby Methods, this happens automatically when you connect the first time to a Server.
```ruby
hiredis["foo"] = "bar"
hiredis["foo"]
hiredis.incr("bar")
```

If you later on want to add more shortcut methods, because the first Server you connected to is of a lower version than the others, you can call
```ruby
Hiredis.create_shortcuts(hiredis)
```

Pipelining
```ruby
hiredis.queue(:set, "foo", "bar")
hiredis.queue(:get, "foo")
hiredis.reply
{'fraction_non_alphanumeric': 0.14070588235294118, 'fraction_numerical': 0.011294117647058824, 'mean_word_length': 4.988732394366197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2905059', 'n_tokens_mistral': 801, 'n_tokens_neox': 732, 'n_words': 239}