Giter Site home page Giter Site logo

mruby-redis's Introduction

mruby-redis Build Status

Hiredis binding for mruby. Hiredis is a minimalistic C client library for the Redis database. Redis is an open source, BSD-licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Plese visit redis' official website for more details about Redis.

Running Redis might be impossible for memory/CPU-constrained environments, so we can recommend mruby-vedis. vedis is an embeddable datastore distributed as a C library. It supports over 70 commands similar to Redis, but runs in memory (hence doesn't require a networking layer). Please visit vedis' website for more details.

INSTALLATION

Using mrbgems

Add conf.gem line to build_config.rb:

MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :git => 'https://github.com/matsumoto-r/mruby-redis.git'
end

USAGE

Connecting to a Redis server

client = Redis.new "127.0.0.1", 6379, 2 # Connect to the server
client.select 0                         # Select the database
client.auth "secret"                    # Required if Redis is password-protected

Commands

Redis#auth doc

client.auth "secret"

Redis#[]=

TBD

Redis#[]

client["key"]

Redis#bulk_reply

TBD

Redis#close

TBD

Redis#decr doc

client.decr "key"

Redis#decrby doc

TBD

Redis#del doc

client.del "key"

Redis#discard doc

# discard the transaction
client.discard

Redis#exec doc

# execute the transaction
client.exec

Redis#exists? doc

client.exists?("key")

Redis#expire doc

TBD

Redis#flushall doc

client.flushall

Redis#flushdb doc

client.flushdb

Redis#get doc

client.get "key"

Redis#hdel doc

client.hdel "myhash", "field1"

Redis#hexists? doc

client.hexists? "myhash", "field1"

Redis#hget doc

client.hget "myhash", "field1"

Redis#hgetall doc

TBD

Redis#hkeys doc

TBD

Redis#hmset doc

client.hmset "myhash", "field1", "a", "field2", "b"

Redis#hmget doc

client.hmget "myhash", "field1", "field2"

Redis#hvals doc

client.hvals "myhash"

Redis#hset doc

client.hset "myhash", "field1", "a"

Redis#hsetnx doc

client.hsetnx "myhash", "field1", "a"

Redis#hincrby doc

client.hincrby "myhash", "field", 1

Redis#incr doc

client.incr "key"

Redis#incrby doc

TBD

Redis#keys doc

TBD

Redis#lindex doc

TBD

Redis#llen doc

TBD

Redis#lpop doc

TBD

Redis#lpush doc

TBD

Redis#lrange doc

client.lrange "logs", 0, -1

Redis#ltrim doc

client.ltrim "logs", 1, -1

Redis#multi doc

# start new transaction. Its finished by exec or discard
client.multi

Redis#ping doc

pong = client.ping

Redis#publish doc

number_of_subscribed_clients = client.publish "queue", "some value"

Redis#pfadd doc

number_of_internal_registers_altered = client.pfadd "hyperloglog_structure", "some value"

Redis#pfcount doc

approximated_number_of_unique_elements = client.pfcount "hyperloglog_structure"

Redis#pfmerge doc

client.pfmerge "hll3", "hll1", "hll2"

Redis#queue doc

TBD

Redis#randomkey doc

TBD

Redis#reply doc

TBD

Redis#rpop doc

TBD

Redis#rpush doc

TBD

Redis#sadd doc

TBD

Redis#scard doc

TBD

Redis#set doc

client.set key, "200"

Redis#sismember doc

TBD

Redis#smembers doc

TBD

Redis#spop doc

TBD

Redis#srem doc

client.srem "set", "fuge", "hoga"

Redis#ttl doc

TBD

Redis#unwatch doc

client.unwatch

Redis#watch doc

# watch key(s) for a transaction
client.watch "key1", "key2"

Redis#zadd doc

client.zadd "hs", 80, "a"

Redis#zcard doc

TBD

Redis#zrange doc

client.zrange "hs", 0, -1

Redis#zrank doc

client.zrank "hs", "a"

Redis#zrevrange doc

client.zrevrange "hs", 0, -1

Redis#zrevrank doc

client.zrevrank "hs", "a"

Redis#zscore doc

client.zscore "hs", "a"

See example/redis.rb for more details.

LICENSE

MIT License - Copyright (c) mod_mruby developers 2012

mruby-redis's People

Contributors

aki017 avatar asmod4n avatar franckverrot avatar hfm avatar hsbt avatar jerry-tao avatar keizo042 avatar matsumotory avatar mattn avatar n0ts avatar sawanoboly avatar schmurfy avatar suzukaze avatar syucream avatar take-cheeze avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.