Merge branch 'feature/session-cache' into 'develop'
Session and user caching See merge request gab/social/gab-social!51
This commit is contained in:
commit
0120a2b361
|
@ -63,7 +63,10 @@ class Api::BaseController < ApplicationController
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def current_user
|
||||
|
|
|
@ -94,7 +94,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def cache_collection(raw, klass)
|
||||
|
|
|
@ -43,7 +43,7 @@ module GabSocial
|
|||
module MigrationHelpers
|
||||
# Stub for Database.postgresql? from GitLab
|
||||
def self.postgresql?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('postgresql').zero?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('postgresql_makara').zero?
|
||||
end
|
||||
|
||||
# Stub for Database.mysql? from GitLab
|
||||
|
@ -57,7 +57,8 @@ module GabSocial
|
|||
if GabSocial::MigrationHelpers.postgresql?
|
||||
'information_schema.role_table_grants'
|
||||
else
|
||||
'mysql.user'
|
||||
'information_schema.role_table_grants'
|
||||
#'mysql.user'
|
||||
end
|
||||
|
||||
def self.scope_to_current_user
|
||||
|
|
Loading…
Reference in New Issue