Browse Source

Adds caching

Lou 3 years ago
parent
commit
203c9c6696
2 changed files with 4 additions and 0 deletions
  1. 2
    0
      app/serializers/activity_serializer.rb
  2. 2
    0
      app/serializers/user_serializer.rb

+ 2
- 0
app/serializers/activity_serializer.rb View File

1
 class ActivitySerializer
1
 class ActivitySerializer
2
   include JSONAPI::Serializer
2
   include JSONAPI::Serializer
3
   attributes :name, :author_id, :description, :client
3
   attributes :name, :author_id, :description, :client
4
+
5
+  cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour
4
 end
6
 end

+ 2
- 0
app/serializers/user_serializer.rb View File

2
   include JSONAPI::Serializer
2
   include JSONAPI::Serializer
3
   attributes :email, :username
3
   attributes :email, :username
4
   has_many :activities
4
   has_many :activities
5
+
6
+  cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour
5
 end
7
 end

Loading…
Cancel
Save