about summary refs log tree commit diff
path: root/app/controllers/api/v1
diff options
context:
space:
mode:
authormultiple creatures <multiple_creatures@monsterware.dev>2020-01-17 10:36:42 +0000
committermultiple creatures <multiple_creatures@monsterware.dev>2020-01-17 10:36:42 +0000
commitd2acdf2ea68dce252e827041d226d4402369669b (patch)
treec4c8acbd7b1b745aadeb60547639f341fd7d7da8 /app/controllers/api/v1
parent753d06495189dd6ffd95ea91028cc2a03866e974 (diff)
parent7b4381b4bdd2e3535b907abfe5f5ffa702d692aa (diff)
Merge pull request 'Port CacheConcern from upstream to define render_with_cache' (#13) from blueraccoon/port-cacheconcern into master
Reviewed-on: https://monsterware.dev/monsterpit/mastodon/pulls/13
Diffstat (limited to 'app/controllers/api/v1')
-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..e3689a269 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