Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matsumotory/mruby-vedis
vedis binding by mruby
https://github.com/matsumotory/mruby-vedis
Last synced: about 1 month ago
JSON representation
vedis binding by mruby
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-vedis
- Owner: matsumotory
- License: other
- Created: 2013-11-09T15:14:28.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T13:53:52.000Z (over 1 year ago)
- Last Synced: 2024-08-03T08:02:34.024Z (4 months ago)
- Language: C
- Size: 197 KB
- Stars: 34
- Watchers: 9
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mruby - mruby-vedis - Binding vedit for mruby. Vedis is a embeddable datastore. (Database)
README
# mruby-vedis [![Build Status](https://travis-ci.org/matsumoto-r/mruby-vedis.png?branch=master)](https://travis-ci.org/matsumoto-r/mruby-vedis)
Binding vedis for mruby.Vedis is a embeddable datastore and self-contained C library that supports over 70 commands similar to Redis.
The major difference from Redis is no networking layer since Vedis runs in the same process of the host application.
Please see the official [Vedis homepage](http://vedis.symisc.net/index.html) for more detail.
## Install by mrbgems
Add the following line to `build_config.rb`:
```ruby
MRuby::Build.new do |conf|# ... (snip) ...
conf.gem :github => 'matsumoto-r/mruby-vedis'
end
```## Usage
```ruby
# In-Memory
v = Vedis.new# On-Disk
# v = Vedis.new "/path/to/vedis.db"# sym ok
v["test"] = "bbb"
v[:hoge] = 2
v[:foo] = 3
v.set :fuga, "aaa"# exec
r1 = v.exec "MSET username james age 27 mail [email protected]"
r2 = v.exec "MGET username age mail"p v["test"] #=> "bbb"
p v[:hoge] #=> "2"
p v["foo"] #=> "3"
p v.get :fuga #=> "aaa"
p r1 #=> nil
p r2 #=> ["james", "27", "[email protected]"]
```## Benchmark comparing Vedis with Redis
### Simple benchmark
```ruby
class SimpleBenchmarkdef initialize(width = 0)
@width = width
enddef measure(label)
start = Time.now
yield if block_given?
passed = Time.now - startputs "#{make_fixed_label(label)}passed time #{passed} sec"
enddef make_fixed_label(label)
if @width - label.length > 0
label + ' ' * (@width - label.length)
else
label
end
endend
benchmark = SimpleBenchmark.new
r = Redis.new "127.0.0.1", 6379
v = Vedis.new
n = 100000[r, v].each do |kvs|
benchmark.measure("#{kvs.class}: ") do
n.times do |t|
kvs.set t.to_s, t.to_s
end
end
endr.close
v.close
```### Results
```bash
$ mruby test_vedis_redis.rb
Redis: passed time 10.785598 sec
Vedis: passed time 0.06595 sec
```## License
mruby-vedis is licensed under the Sleepycat License, see the LICENSE file.