mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
added standard redis key name constants
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user