Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
ffc604a2
Commit
ffc604a2
authored
Apr 30, 2017
by
lain
Browse files
Use cache for user info data.
Later these should be persisted in the user.
parent
8a0d2b33
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
ffc604a2
...
...
@@ -122,4 +122,9 @@ def get_cached_by_nickname(nickname) do
key
=
"nickname:
#{
nickname
}
"
Cachex
.
get!
(
:user_cache
,
key
,
fallback:
fn
(
_
)
->
Repo
.
get_by
(
User
,
nickname:
nickname
)
end
)
end
def
get_cached_user_info
(
user
)
do
key
=
"user_info:
#{
user
.
id
}
"
Cachex
.
get!
(
:user_cache
,
key
,
fallback:
fn
(
_
)
->
user_info
(
user
)
end
)
end
end
lib/pleroma/web/twitter_api/representers/user_representer.ex
View file @
ffc604a2
...
...
@@ -11,7 +11,7 @@ def to_map(user, opts) do
false
end
user_info
=
User
.
user_info
(
user
)
user_info
=
User
.
get_cached_
user_info
(
user
)
map
=
%{
"id"
=>
user
.
id
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment