DEV: uses Discourse.redis instead of $redis

DEV: uses Discourse.redis instead of $redis

diff --git a/lib/opsgenie_schedule.rb b/lib/opsgenie_schedule.rb
index 905c652..99b0bec 100644
--- a/lib/opsgenie_schedule.rb
+++ b/lib/opsgenie_schedule.rb
@@ -25,7 +25,7 @@ class OpsgenieSchedule
   private
 
   def self.user_rotations
-    if cached_rotations = $redis.get(redis_key)
+    if cached_rotations = Discourse.redis.get(redis_key)
       return MessagePack.unpack(cached_rotations)
     end
 
@@ -50,7 +50,7 @@ class OpsgenieSchedule
       end
     end
 
-    $redis.setex(redis_key, 1.day, new_rotations.to_msgpack)
+    Discourse.redis.setex(redis_key, 1.day, new_rotations.to_msgpack)
     new_rotations
   end
 
diff --git a/spec/lib/opsgenie_schedule_spec.rb b/spec/lib/opsgenie_schedule_spec.rb
index 5f981a9..f15bb91 100644
--- a/spec/lib/opsgenie_schedule_spec.rb
+++ b/spec/lib/opsgenie_schedule_spec.rb
@@ -153,7 +153,7 @@ RSpec.describe OpsgenieSchedule do
   end
 
   after do
-    $redis.del(described_class.send(:redis_key))
+    Discourse.redis.del(described_class.send(:redis_key))
   end
 
   describe '.users_on_rotation' do

GitHub sha: 1de45fc7

1 Like