Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
memcache
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
memcache
Commits
8c3dfe4a
Commit
8c3dfe4a
authored
Jan 20, 2017
by
Jeremy Andrews
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#903914
by catch, Jeremy: Per-bin minimum cache lifetime
parent
d982b039
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.txt
+13
-0
13 additions, 0 deletions
README.txt
memcache.inc
+3
-3
3 additions, 3 deletions
memcache.inc
with
16 additions
and
3 deletions
README.txt
+
13
−
0
View file @
8c3dfe4a
...
...
@@ -194,6 +194,19 @@ When adjusting these variables, be aware that:
standard web server timeouts (i.e. 15 seconds vs. apache's default of
30 seconds).
## CACHE LIFETIME ##
Memcache respects Drupal core's minimum cache lifetime configuration. This
setting affects all cached items, not just pages. In some cases, it may
be desirable to cache different types of items for different amounts of time.
You can override the minimum cache lifetime on a per-bin basis in settings.php.
For example:
// Cache pages for 60 seconds.
$conf['cache_lifetime_cache_page'] = 60;
// Cache menus for 10 minutes.
$conf['cache_lifetime_menu'] = 600;
## EXAMPLES ##
Example 1:
...
...
This diff is collapsed.
Click to expand it.
memcache.inc
+
3
−
3
View file @
8c3dfe4a
...
...
@@ -97,8 +97,8 @@ class MemCacheDrupal implements DrupalCacheInterface {
// Clean-up the per-user cache expiration session data, so that the session
// handler can properly clean-up the session data for anonymous users.
if
(
isset
(
$_SESSION
[
'cache_flush'
]))
{
$expire
=
REQUEST_TIME
-
variable_get
(
'cache_lifetime'
,
0
);
foreach
(
$_SESSION
[
'cache_flush'
]
as
$bin
=>
$timestamp
)
{
$expire
=
REQUEST_TIME
-
variable_get
(
'cache_lifetime_'
.
$this
->
bin
,
variable_get
(
'cache_lifetime'
,
0
));
if
(
$timestamp
<
$expire
)
{
unset
(
$_SESSION
[
'cache_flush'
][
$bin
]);
}
...
...
@@ -273,7 +273,7 @@ class MemCacheDrupal implements DrupalCacheInterface {
// whether or not the cached item is still valid.
$this
->
cache_content_flush
=
time
();
$this
->
variable_set
(
'cache_content_flush_'
.
$this
->
bin
,
$this
->
cache_content_flush
);
if
(
variable_get
(
'cache_lifetime'
,
0
))
{
if
(
variable_get
(
'cache_lifetime_'
.
$this
->
bin
,
variable_get
(
'cache_lifetime'
,
0
))
)
{
// We store the time in the current user's session. We then simulate
// that the cache was flushed for this user by not returning cached
// data to this user that was cached before the timestamp.
...
...
@@ -601,7 +601,7 @@ class MemCacheDrupal implements DrupalCacheInterface {
public
function
reloadVariables
()
{
$this
->
wildcard_flushes
=
variable_get
(
'memcache_wildcard_flushes'
,
array
());
$this
->
invalidate
=
variable_get
(
'memcache_wildcard_invalidate'
,
MEMCACHE_WILDCARD_INVALIDATE
);
$this
->
cache_lifetime
=
variable_get
(
'cache_lifetime'
,
0
);
$this
->
cache_lifetime
=
variable_get
(
'cache_lifetime_'
.
$this
->
bin
,
variable_get
(
'cache_lifetime'
,
0
)
)
;
$this
->
cache_flush
=
variable_get
(
'cache_flush_'
.
$this
->
bin
);
$this
->
cache_content_flush
=
variable_get
(
'cache_content_flush_'
.
$this
->
bin
,
0
);
$this
->
cache_temporary_flush
=
variable_get
(
'cache_temporary_flush_'
.
$this
->
bin
,
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment