Browse Source

Refactoring: Deprecate custom Cache implementation and wrap native Rails cache instead.

Mantas Masalskis 3 years ago
parent
commit
c45b5ac51f

+ 1 - 1
app/controllers/channels_twitter_controller.rb

@@ -48,7 +48,7 @@ class ChannelsTwitterController < ApplicationController
   end
   end
 
 
   def webhook_verify
   def webhook_verify
-    external_credential = Cache.get('external_credential_twitter')
+    external_credential = Cache.read('external_credential_twitter')
     if !external_credential && ExternalCredential.exists?(name: 'twitter')
     if !external_credential && ExternalCredential.exists?(name: 'twitter')
       external_credential = ExternalCredential.find_by(name: 'twitter').credentials
       external_credential = ExternalCredential.find_by(name: 'twitter').credentials
     end
     end

+ 1 - 1
app/models/application_model/can_associations.rb

@@ -119,7 +119,7 @@ returns
   def attributes_with_association_ids
   def attributes_with_association_ids
 
 
     key = "#{self.class}::aws::#{id}"
     key = "#{self.class}::aws::#{id}"
-    cache = Cache.get(key)
+    cache = Cache.read(key)
     return cache if cache
     return cache if cache
 
 
     attributes = self.attributes
     attributes = self.attributes

+ 1 - 1
app/models/application_model/can_latest_change.rb

@@ -19,7 +19,7 @@ returns
 
 
     def latest_change
     def latest_change
       key        = "#{name}_latest_change"
       key        = "#{name}_latest_change"
-      updated_at = Cache.get(key)
+      updated_at = Cache.read(key)
 
 
       return updated_at if updated_at
       return updated_at if updated_at
 
 

+ 1 - 1
app/models/application_model/has_cache.rb

@@ -47,7 +47,7 @@ module ApplicationModel::HasCache
 
 
     def cache_get(data_id)
     def cache_get(data_id)
       key = "#{self}::#{data_id}"
       key = "#{self}::#{data_id}"
-      Cache.get(key)
+      Cache.read(key)
     end
     end
   end
   end
 end
 end

+ 2 - 2
app/models/calendar.rb

@@ -32,7 +32,7 @@ returns calendar object
     end
     end
 
 
     # prevent multiple setups for same ip
     # prevent multiple setups for same ip
-    cache = Cache.get('Calendar.init_setup.done')
+    cache = Cache.read('Calendar.init_setup.done')
     return if cache && cache[:ip] == ip
     return if cache && cache[:ip] == ip
 
 
     Cache.write('Calendar.init_setup.done', { ip: ip }, { expires_in: 1.hour })
     Cache.write('Calendar.init_setup.done', { ip: ip }, { expires_in: 1.hour })
@@ -156,7 +156,7 @@ returns
     # only sync every 5 days
     # only sync every 5 days
     if id
     if id
       cache_key = "CalendarIcal::#{id}"
       cache_key = "CalendarIcal::#{id}"
-      cache = Cache.get(cache_key)
+      cache = Cache.read(cache_key)
       return if !last_log && cache && cache[:ical_url] == ical_url
       return if !last_log && cache && cache[:ical_url] == ical_url
     end
     end
 
 

+ 1 - 1
app/models/cti/driver/placetel.rb

@@ -83,7 +83,7 @@ class Cti::Driver::Placetel < Cti::Driver::Base
   def load_voip_users
   def load_voip_users
     return {} if @config.blank? || @config[:api_token].blank?
     return {} if @config.blank? || @config[:api_token].blank?
 
 
-    list = Cache.get('placetelGetVoipUsers')
+    list = Cache.read('placetelGetVoipUsers')
     return list if list
     return list if list
 
 
     response = UserAgent.post(
     response = UserAgent.post(

+ 1 - 1
app/models/cti/driver/sipgate_io.rb

@@ -27,7 +27,7 @@ class Cti::Driver::SipgateIo < Cti::Driver::Base
   def load_voip_users
   def load_voip_users
     return {} if @config.blank? || @config[:api_user].blank? || @config[:api_password].blank?
     return {} if @config.blank? || @config[:api_user].blank? || @config[:api_password].blank?
 
 
-    list = Cache.get('sipgateUserList')
+    list = Cache.read('sipgateUserList')
     return list if list
     return list if list
 
 
     url = 'https://api.sipgate.com/v2/users'
     url = 'https://api.sipgate.com/v2/users'

+ 1 - 1
app/models/karma/activity_log.rb

@@ -26,7 +26,7 @@ add karma activity log of an object
     # to skip the time loss of the transaction
     # to skip the time loss of the transaction
     # to increase performance
     # to increase performance
     if !force
     if !force
-      cache = Cache.get("Karma::ActivityLog.add::#{activity.once_ttl.seconds}::#{action}::#{user.id}::#{object}::#{o_id}")
+      cache = Cache.read("Karma::ActivityLog.add::#{activity.once_ttl.seconds}::#{action}::#{user.id}::#{object}::#{o_id}")
       return cache if cache
       return cache if cache
     end
     end
 
 

+ 1 - 1
app/models/knowledge_base/answer.rb

@@ -27,7 +27,7 @@ class KnowledgeBase::Answer < ApplicationModel
   def attributes_with_association_ids
   def attributes_with_association_ids
     key = "#{self.class}::aws::#{id}"
     key = "#{self.class}::aws::#{id}"
 
 
-    cache = Cache.get(key)
+    cache = Cache.read(key)
     return cache if cache
     return cache if cache
 
 
     attrs = super
     attrs = super

+ 1 - 1
app/models/knowledge_base/answer/translation.rb

@@ -28,7 +28,7 @@ class KnowledgeBase::Answer::Translation < ApplicationModel
   def attributes_with_association_ids
   def attributes_with_association_ids
     key = "#{self.class}::aws::#{id}"
     key = "#{self.class}::aws::#{id}"
 
 
-    cache = Cache.get(key)
+    cache = Cache.read(key)
     return cache if cache
     return cache if cache
 
 
     attrs = super
     attrs = super

Some files were not shown because too many files changed in this diff