about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorHolly "Frinkeldoodle" Lotor <admin@frinkel.tech>2020-01-17 07:07:03 +0000
committerHolly "Frinkeldoodle" Lotor <admin@frinkel.tech>2020-01-17 07:32:59 +0000
commit93151f0c51a0418cd51e270a0834c92a771910ab (patch)
tree800f7af97950280ed591129e3df6aee5641e2ba5 /app/controllers/api
parent753d06495189dd6ffd95ea91028cc2a03866e974 (diff)
Port render_with_cache, CacheConcern from upstream
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/custom_emojis_controller.rb5
-rw-r--r--app/controllers/api/v1/instances/activity_controller.rb3
-rw-r--r--app/controllers/api/v1/instances/peers_controller.rb3
3 files changed, 6 insertions, 5 deletions
diff --git a/app/controllers/api/v1/custom_emojis_controller.rb b/app/controllers/api/v1/custom_emojis_controller.rb
index 1bb19a09d..6ddb5936c 100644
--- a/app/controllers/api/v1/custom_emojis_controller.rb
+++ b/app/controllers/api/v1/custom_emojis_controller.rb
@@ -6,8 +6,7 @@ class Api::V1::CustomEmojisController < Api::BaseController
   skip_before_action :set_cache_headers
 
   def index
-    render_cached_json('api:v1:custom_emojis', expires_in: 1.minute) do
-      ActiveModelSerializers::SerializableResource.new(CustomEmoji.local.where(disabled: false), each_serializer: REST::CustomEmojiSerializer)
-    end
+    expires_in 3.minutes, public: true
+    render_with_cache(each:serializer: REST:CustomEmojiSerializer) { CustomEmoji.local.where(disabled: false) }
   end
 end
diff --git a/app/controllers/api/v1/instances/activity_controller.rb b/app/controllers/api/v1/instances/activity_controller.rb
index 09edfe365..d0080c5c2 100644
--- a/app/controllers/api/v1/instances/activity_controller.rb
+++ b/app/controllers/api/v1/instances/activity_controller.rb
@@ -7,7 +7,8 @@ class Api::V1::Instances::ActivityController < Api::BaseController
   respond_to :json
 
   def show
-    render_cached_json('api:v1:instances:activity:show', expires_in: 1.day) { activity }
+    expires_in 1.day, public: true
+    render_with_cache json: :activity, expires_in: 1.day
   end
 
   private
diff --git a/app/controllers/api/v1/instances/peers_controller.rb b/app/controllers/api/v1/instances/peers_controller.rb
index 93c4c45af..bb04e604d 100644
--- a/app/controllers/api/v1/instances/peers_controller.rb
+++ b/app/controllers/api/v1/instances/peers_controller.rb
@@ -7,7 +7,8 @@ class Api::V1::Instances::PeersController < Api::BaseController
   respond_to :json
 
   def index
-    render_cached_json('api:v1:instances:peers:index', expires_in: 1.day) { actively_federated_domains }
+    expires_in 1.day, public: true
+    render_with_cache(expires_in: 1.day) { actively_federated_domains }
   end
 
   private