diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/application.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/user.ex | 11 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api_controller.ex | 4 |
4 files changed, 15 insertions, 11 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index e5bd17ced..86b6c0c1e 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -14,10 +14,11 @@ 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]), - supervisor(ConCache, [[ - ttl_check: :timer.seconds(1), - ttl: :timer.seconds(5) - ], [name: :users]]) + worker(Cachex, [:user_cache, [ + default_ttl: 5000, + ttl_interval: 1000, + limit: 500 + ]]) ] # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 418522172..86b4b8b5e 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -87,15 +87,12 @@ defmodule Pleroma.User do end def get_cached_by_ap_id(ap_id) do - ConCache.get_or_store(:users, "ap_id:#{ap_id}", fn() -> - # Return false so the cache will store it. - Repo.get_by(User, ap_id: ap_id) || false - end) + key = "ap_id:#{ap_id}" + Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, ap_id: ap_id) end) end def get_cached_by_nickname(nickname) do - ConCache.get_or_store(:users, "nickname:#{nickname}", fn() -> - Repo.get_by(User, nickname: nickname) || false - end) + key = "nickname:#{nickname}" + Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, nickname: nickname) end) end end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 2d7c25b50..0446f622b 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -21,6 +21,8 @@ defmodule Pleroma.Web.Router do scope "/api", Pleroma.Web do pipe_through :api + + get "/help/test", TwitterAPI.Controller, :help_test get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_timeline get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index bafd878fc..32d352d79 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -88,6 +88,10 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> send_resp(200, response) end + def help_test(conn, _params) do + conn |> json_reply(200, Poison.encode!("ok")) + end + def upload_json(conn, %{"media" => media}) do response = TwitterAPI.upload(media, "json") conn |