Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
33a8baf3
Commit
33a8baf3
authored
Jan 16, 2012
by
Holger Just
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pulls/780/setting-cache' of
https://github.com/finnlabs/chiliproject
into unstable
parents
d7ebffb7
10e16e9a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
21 additions
and
17 deletions
+21
-17
application_controller.rb
app/controllers/application_controller.rb
+0
-2
setting.rb
app/models/setting.rb
+14
-14
account_controller_test.rb
test/functional/account_controller_test.rb
+1
-0
issue_statuses_controller_test.rb
test/functional/issue_statuses_controller_test.rb
+1
-0
test_helper.rb
test/test_helper.rb
+1
-1
changeset_test.rb
test/unit/changeset_test.rb
+1
-0
journal_observer_test.rb
test/unit/journal_observer_test.rb
+1
-0
i18n_test.rb
test/unit/lib/redmine/i18n_test.rb
+1
-0
news_test.rb
test/unit/news_test.rb
+1
-0
No files found.
app/controllers/application_controller.rb
View file @
33a8baf3
...
...
@@ -75,8 +75,6 @@ class ApplicationController < ActionController::Base
end
def
user_setup
# Check the settings cache for each request
Setting
.
check_cache
# Find the current user
User
.
current
=
find_current_user
end
...
...
app/models/setting.rb
View file @
33a8baf3
...
...
@@ -97,13 +97,13 @@ class Setting < ActiveRecord::Base
# Returns the value of the setting named name
def
self
.
[]
(
name
)
Marshal
.
load
(
Rails
.
cache
.
fetch
(
"chiliproject/setting/
#{
name
}
"
)
{
Marshal
.
dump
(
find_or_default
(
name
).
value
)})
Marshal
.
load
(
Rails
.
cache
.
fetch
(
self
.
cache_key
(
name
)
)
{
Marshal
.
dump
(
find_or_default
(
name
).
value
)})
end
def
self
.
[]=
(
name
,
v
)
setting
=
find_or_default
(
name
)
setting
.
value
=
(
v
?
v
:
""
)
Rails
.
cache
.
delete
"chiliproject/setting/
#{
name
}
"
Rails
.
cache
.
delete
self
.
cache_key
(
name
)
setting
.
save
setting
.
value
end
...
...
@@ -137,23 +137,19 @@ class Setting < ActiveRecord::Base
Object
.
const_defined?
(
:OpenID
)
&&
self
[
:openid
].
to_i
>
0
end
# Checks if settings have changed since the values were read
# and clears the cache hash if it's the case
# Called once per request
# Deprecation Warning: This method is no longer available. There is no
# replacement.
def
self
.
check_cache
settings_updated_on
=
Setting
.
maximum
(
:updated_on
)
cache_cleared_on
=
Rails
.
cache
.
read
(
'chiliproject/setting-cleared_on'
)
cache_cleared_on
=
cache_cleared_on
?
Marshal
.
load
(
cache_cleared_on
)
:
Time
.
now
if
settings_updated_on
&&
cache_cleared_on
<=
settings_updated_on
clear_cache
end
ActiveSupport
::
Deprecation
.
warn
"The Setting.check_cache method is "
+
"deprecated and will be removed in the future. There should be no "
+
"replacement for this functionality needed."
end
# Clears all of the Setting caches
def
self
.
clear_cache
Rails
.
cache
.
delete_matched
(
/^chiliproject\/setting\/.+$/
)
Rails
.
cache
.
write
(
'chiliproject/setting-cleared_on'
,
Marshal
.
dump
(
Time
.
now
))
logger
.
info
'Settings cache cleared.'
if
logger
ActiveSupport
::
Deprecation
.
warn
"The Setting.clear_cache method is "
+
"deprecated and will be removed in the future. There should be no "
+
"replacement for this functionality needed."
end
private
...
...
@@ -165,4 +161,8 @@ private
setting
=
find_by_name
(
name
)
setting
||=
new
(
:name
=>
name
,
:value
=>
@@available_settings
[
name
][
'default'
])
if
@@available_settings
.
has_key?
name
end
def
self
.
cache_key
(
name
)
"chiliproject/setting/
#{
Setting
.
maximum
(
:updated_on
).
to_i
}
/
#{
name
}
"
end
end
test/functional/account_controller_test.rb
View file @
33a8baf3
...
...
@@ -21,6 +21,7 @@ class AccountControllerTest < ActionController::TestCase
fixtures
:users
,
:roles
def
setup
super
@controller
=
AccountController
.
new
@request
=
ActionController
::
TestRequest
.
new
@response
=
ActionController
::
TestResponse
.
new
...
...
test/functional/issue_statuses_controller_test.rb
View file @
33a8baf3
...
...
@@ -23,6 +23,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
fixtures
:issue_statuses
,
:issues
def
setup
super
@controller
=
IssueStatusesController
.
new
@request
=
ActionController
::
TestRequest
.
new
@response
=
ActionController
::
TestResponse
.
new
...
...
test/test_helper.rb
View file @
33a8baf3
...
...
@@ -47,7 +47,7 @@ class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
def
setup
super
Setting
.
clear_cache
Rails
.
cache
.
clear
end
def
log_user
(
login
,
password
)
...
...
test/unit/changeset_test.rb
View file @
33a8baf3
...
...
@@ -19,6 +19,7 @@ class ChangesetTest < ActiveSupport::TestCase
:custom_fields
,
:custom_values
,
:users
,
:members
,
:member_roles
,
:trackers
def
setup
super
end
def
test_ref_keywords_any
...
...
test/unit/journal_observer_test.rb
View file @
33a8baf3
...
...
@@ -15,6 +15,7 @@ require File.expand_path('../../test_helper', __FILE__)
class
JournalObserverTest
<
ActiveSupport
::
TestCase
def
setup
super
@user
=
User
.
generate!
(
:mail_notification
=>
'all'
)
@project
=
Project
.
generate!
User
.
add_to_project
(
@user
,
@project
,
Role
.
generate!
(
:permissions
=>
[
:view_issues
,
:edit_issues
]))
...
...
test/unit/lib/redmine/i18n_test.rb
View file @
33a8baf3
...
...
@@ -18,6 +18,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase
include
ActionView
::
Helpers
::
NumberHelper
def
setup
super
@hook_module
=
Redmine
::
Hook
end
...
...
test/unit/news_test.rb
View file @
33a8baf3
...
...
@@ -22,6 +22,7 @@ class NewsTest < ActiveSupport::TestCase
def
setup
super
end
def
test_create_should_send_email_notification
...
...
Write
Preview
Markdown
is supported
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