This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 57a16006796594214c1e8d0ecff0461a385ebd07
tree 613e526511836bbfbcf6f18443e8a140206f1de3
parent 55db89debef935f74177ab44e484ee7770002a42
tree 613e526511836bbfbcf6f18443e8a140206f1de3
parent 55db89debef935f74177ab44e484ee7770002a42
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Wed Oct 14 00:39:18 -0700 2009 | |
| |
README.rdoc | Sat Oct 24 20:06:42 -0700 2009 | |
| |
Rakefile | Sun Oct 18 14:05:32 -0700 2009 | |
| |
VERSION | Wed Oct 21 01:11:46 -0700 2009 | |
| |
bench.rb | Wed Oct 14 00:21:22 -0700 2009 | |
| |
examples/ | Wed Oct 14 00:21:22 -0700 2009 | |
| |
lib/ | Sat Oct 24 20:02:18 -0700 2009 | |
| |
redis-model.gemspec | Wed Oct 21 01:44:48 -0700 2009 | |
| |
spec/ | Sat Oct 24 20:02:18 -0700 2009 |
README.rdoc
redis-model
Minimal model support for [redis-rb](github.com/ezmobius/redis-rb). Directly maps ruby properties to model_name:id:field_name keys in redis. Scalar, list and set properties are supported.
Values can be marshaled to/from Integer, Float, DateTime, JSON. See Redis::Model::Marshal for more info.
Define
require 'redis/model'
class User < Redis::Model
field :name, :string
field :created, :datetime
field :profile, :json
list :posts, :json
set :followers, :int
end
Write
u = User.with_key(1)
u.name = 'Joe' # set user:1:name Joe
u.created = DateTime.now # set user:1:created 2009-10-05T12:09:56+0400
u.profile = { # set user:1:profile {"sex":"M","about":"Lorem","age":23}
:age => 23,
:sex => 'M',
:about => 'Lorem'
}
u.posts << { # rpush user:1:posts {"title":"Hello world!","text":"lorem"}
:title => "Hello world!",
:text => "lorem"
}
u.followers << 2 # sadd user:1:followers 2
Read
u = User.with_key(1)
p u.name # get user:1:name
p u.created.strftime('%m/%d/%Y') # get user:1:created
p u.posts[0,20] # lrange user:1:posts 0 20
p u.posts[0] # lindex user:1:posts 0
p u.followers.has_key?(2) # sismember user:1:followers 2







