added standard redis key name constants

This commit is contained in:
2010-07-20 02:58:58 +03:00
parent de018d7348
commit 1daf8613dd
3 changed files with 9 additions and 4 deletions

View File

@@ -12,6 +12,11 @@ require "redistat/label"
require "redistat/date"
module Redistat
KEY_NEXT_EVENT_ID = "Redistat.next_event_id"
KEY_EVENT_PREFIX = "Redistat.event:"
KEY_LEBELS_PREFIX = "Redistat.lables:"
KEY_EVENT_IDS_SUFFIX = ".event_ids"
# Provides access to the Redis database. This is shared accross all models and instances.
def redis

View File

@@ -11,7 +11,7 @@ module Redistat
end
def save
@saved = (db.set("Redistat:lables:#{@hash}", @name) == "OK")
@saved = (db.set("#{KEY_LEBELS_PREFIX}#{@hash}", @name) == "OK")
self
end

View File

@@ -14,15 +14,15 @@ describe Redistat::Label do
label = Redistat::Label.new(name)
label.save
label.saved?.should be_true
redis.get("Redistat:lables:#{label.hash}").should == name
db.get("#{Redistat::KEY_LEBELS_PREFIX}#{label.hash}").should == name
name = "/contact/us"
label = Redistat::Label.create(name)
label.saved?.should be_true
redis.get("Redistat:lables:#{label.hash}").should == name
db.get("#{Redistat::KEY_LEBELS_PREFIX}#{label.hash}").should == name
end
def redis
def db
Redistat.redis
end