object: split object_cache from user_cache
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 1 Nov 2018 08:30:10 +0000 (08:30 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 1 Nov 2018 08:41:46 +0000 (08:41 +0000)
lib/pleroma/application.ex
lib/pleroma/object.ex
test/object_test.exs

index a89728471f756eaa746fe0282f626bf3fc94845a..a6b921b4507d5e5489fb34f7158561e18139a323 100644 (file)
@@ -16,14 +16,30 @@ defmodule Pleroma.Application do
         supervisor(Pleroma.Web.Endpoint, []),
         # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
         # worker(Pleroma.Worker, [arg1, arg2, arg3]),
-        worker(Cachex, [
-          :user_cache,
+        worker(
+          Cachex,
           [
-            default_ttl: 25000,
-            ttl_interval: 1000,
-            limit: 2500
-          ]
-        ]),
+            :user_cache,
+            [
+              default_ttl: 25000,
+              ttl_interval: 1000,
+              limit: 2500
+            ]
+          ],
+          id: :cachex_user
+        ),
+        worker(
+          Cachex,
+          [
+            :object_cache,
+            [
+              default_ttl: 25000,
+              ttl_interval: 1000,
+              limit: 2500
+            ]
+          ],
+          id: :cachex_object
+        ),
         worker(
           Cachex,
           [
index fddf3845031dd1db697b79bbd0767c876e0497cd..067ecfaf4732d271f7edfa045401efe2b80d279b 100644 (file)
@@ -37,7 +37,7 @@ defmodule Pleroma.Object do
     else
       key = "object:#{ap_id}"
 
-      Cachex.fetch!(:user_cache, key, fn _ ->
+      Cachex.fetch!(:object_cache, key, fn _ ->
         object = get_by_ap_id(ap_id)
 
         if object do
@@ -56,7 +56,7 @@ defmodule Pleroma.Object do
   def delete(%Object{data: %{"id" => id}} = object) do
     with Repo.delete(object),
          Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
-         {:ok, true} <- Cachex.del(:user_cache, "object:#{id}") do
+         {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do
       {:ok, object}
     end
   end
index 3e398776cbf1c78f793f133a90b5d7837b998b80..909605560e6d8015b41e2eb38b583346f51da952 100644 (file)
@@ -42,7 +42,7 @@ defmodule Pleroma.ObjectTest do
 
       Object.delete(cached_object)
 
-      {:ok, nil} = Cachex.get(:user_cache, "object:#{object.data["id"]}")
+      {:ok, nil} = Cachex.get(:object_cache, "object:#{object.data["id"]}")
 
       cached_object = Object.get_cached_by_ap_id(object.data["id"])