소스 검색

Cache objects in dev and prod.

tags/v0.9.9
Roger Braun 7 년 전
부모
커밋
f169de3454
2개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. +9
    -0
      lib/pleroma/object.ex
  2. +1
    -1
      lib/pleroma/web/twitter_api/twitter_api.ex

+ 9
- 0
lib/pleroma/object.ex 파일 보기

@@ -14,6 +14,15 @@ defmodule Pleroma.Object do
where: fragment("? @> ?", object.data, ^%{id: ap_id}))
end

def get_cached_by_ap_id(ap_id) do
if Mix.env == :test do
get_by_ap_id(ap_id)
else
key = "object:#{ap_id}"
Cachex.get!(:user_cache, key, fallback: fn(_) -> get_by_ap_id(ap_id) end)
end
end

def context_mapping(context) do
%Object{data: %{"id" => context}}
end


+ 1
- 1
lib/pleroma/web/twitter_api/twitter_api.ex 파일 보기

@@ -317,7 +317,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do

def context_to_conversation_id(context) do
{:ok, id} = Repo.transaction(fn ->
with %Object{id: id} <- Object.get_by_ap_id(context) do
with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
id
else _e ->
changeset = Object.context_mapping(context)


불러오는 중...
취소
저장