Session and user caching
This commit is contained in:
parent
21096c523d
commit
132c46ac9a
@ -63,7 +63,10 @@ class Api::BaseController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_resource_owner
|
def current_resource_owner
|
||||||
@current_user ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
@current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do
|
||||||
|
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
||||||
|
end
|
||||||
|
#@current_user ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
|
@ -94,7 +94,9 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_session
|
def current_session
|
||||||
@current_session ||= SessionActivation.find_by(session_id: cookies.signed['_session_id'])
|
@current_session ||= Rails.cache.fetch("dk:sess:#{cookies.signed['_session_id']}", expires_in: 25.hours) do
|
||||||
|
SessionActivation.find_by(session_id: cookies.signed['_session_id'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_collection(raw, klass)
|
def cache_collection(raw, klass)
|
||||||
|
@ -43,7 +43,7 @@ module GabSocial
|
|||||||
module MigrationHelpers
|
module MigrationHelpers
|
||||||
# Stub for Database.postgresql? from GitLab
|
# Stub for Database.postgresql? from GitLab
|
||||||
def self.postgresql?
|
def self.postgresql?
|
||||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('postgresql').zero?
|
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('postgresql_makara').zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stub for Database.mysql? from GitLab
|
# Stub for Database.mysql? from GitLab
|
||||||
@ -57,7 +57,8 @@ module GabSocial
|
|||||||
if GabSocial::MigrationHelpers.postgresql?
|
if GabSocial::MigrationHelpers.postgresql?
|
||||||
'information_schema.role_table_grants'
|
'information_schema.role_table_grants'
|
||||||
else
|
else
|
||||||
'mysql.user'
|
'information_schema.role_table_grants'
|
||||||
|
#'mysql.user'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scope_to_current_user
|
def self.scope_to_current_user
|
||||||
|
Loading…
Reference in New Issue
Block a user