diff --git a/lib/redistat.rb b/lib/redistat.rb index 639abae..e524b1e 100644 --- a/lib/redistat.rb +++ b/lib/redistat.rb @@ -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 diff --git a/lib/redistat/label.rb b/lib/redistat/label.rb index e7a4750..4ce940f 100644 --- a/lib/redistat/label.rb +++ b/lib/redistat/label.rb @@ -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 diff --git a/spec/label_spec.rb b/spec/label_spec.rb index b1b68e0..54fdf63 100644 --- a/spec/label_spec.rb +++ b/spec/label_spec.rb @@ -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