Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (33 sloc) 1.01 KB
require 'rubygems'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'redis/types'
Redis::Types.redis = Redis.new(:db => 2)
class User
include Redis::Types
value :name, String
value :created, DateTime
value :profile, Json
list :posts, Json
set :followers, Integer
end
u = User.new(:id => 1)
u.destroy
u.name = 'Joe'
u.created = DateTime.now
u.profile = {
:age => 23,
:sex => 'M',
:about => 'Lorem'
}
u.posts << {
:title => "Hello world!",
:text => "lorem"
}
u.followers << 2
u = User.new(:id => 1)
p u.name
p u.created.strftime('%m/%d/%Y')
p u.profile
p u.posts[0,20]
p u.posts[0]
p u.followers.has_key?(2)