Skip to content

ctoneal/strc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STRC - Super Terrible Redis Clone

STRC is a poor attempt to make a useless Ruby simulation of Redis. Why would you want that? Well, who knows. Maybe you:

  • don’t feel like installing Redis for some reason.

  • need to be able to run tests on a machine without having to install Redis.

  • like badly implemented clones.

I’ll come out and say it, there’s little reason for this to exist, and it’s not really written in a fashion that is what you’d call good. It’s just for shits and giggles. If that’s your thing, read on.

One thing STRC does kind of have going for it is that it’s much more lazy in regards to what you give it. Since you’re passing it Ruby objects, that means you could just plop any old object in as a key or a value, instead of just a string. If that’s something you’re into.

Usage

STRC is distributed as a gem. To install:

% gem install strc

Now you’ve got it all up in your computer. To use:

require 'rubygems'
require 'strc'

strc = STRC.new

Now you could start passing it commands, if they’ve been implemented.

Getting and Setting!

>> strc.set "foo", "bar"
=> "OK"
>> strc.get "foo"
=> "bar"

Sets!

>> strc.sadd "stuff", "abc"
=> 1
>> strc.sadd "stuff", "123", "blah"
=> 2
>> strc.scard "stuff"
=> 3
>> strc.sismember "stuff", "abc"
=> true
>> strc.sismember "stuff", "xyz"
=> false
>> strc.srem "stuff", "blah"
=> true
>> strc.smembers "stuff"
=> ["abc", "123"]

Lists!

>> strc.rpush "poo", "abc", "xyz"
=> 2
>> strc.lpush "poo", "123"
=> 3
>> strc.rpop "poo"
=> "xyz"
>> strc.llen "poo"
=> 2

Hashes!

>> strc.hset "test" "key1" "val1"
=> true
>> strc.hget "test" "key1"
=> "val1"
>> strc.hlen "test"
=> 1
>> strc.hkeys "test"
=> ["key1"]

Command List

Currently, the following commands are implemented:

  • get

  • set

  • setnx

  • del

  • exists

  • append

  • decr

  • decrby

  • incr

  • incrby

  • rename

  • renamenx

  • Sets

    • sadd

    • srem

    • sismember

    • smembers

    • scard

    • sinter

    • sinterstore

    • sdiff

    • sdiffstore

    • sunion

    • sunionstore

    • smove

    • srandmember

    • spop

  • Lists

    • lrange

    • llen

    • lpush

    • lpushx

    • lpop

    • rpush

    • rpushx

    • rpop

    • lindex

    • lset

    • ltrim

    • rpoplpush

  • Hashes

    • hset

    • hsetnx

    • hget

    • hgetall

    • hdel

    • hexists

    • hkeys

    • hvals

    • hlen

History

  • 0.0.4 - Some hash commands done.

  • 0.0.3 - Some list commands done.

  • 0.0.2 - Set commands done. Most general commands done.

  • 0.0.1 - Initial release. Does some basic things.

About

Super Terrible Redis Clone

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages