Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
M
memcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
memcache
Commits
687433da
Commit
687433da
authored
Sep 16, 2011
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1281484
by Berdir: wildcards clears broken on subsequent requests.
parent
a0b7cb6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
29 deletions
+27
-29
dmemcache.inc
dmemcache.inc
+4
-5
memcache.inc
memcache.inc
+11
-12
tests/memcache.test
tests/memcache.test
+12
-12
No files found.
dmemcache.inc
View file @
687433da
...
...
@@ -129,7 +129,7 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
foreach
(
$keys
as
$key
=>
$cid
)
{
$full_key
=
dmemcache_key
(
$cid
,
$bin
);
$statistics
[
$full_key
]
=
array
(
'getMulti'
,
$bin
,
$full_key
);
$full_keys
[]
=
$full_key
;
$full_keys
[
$cid
]
=
$full_key
;
}
$results
=
array
();
if
(
$mc
||
(
$mc
=
dmemcache_object
(
$bin
)))
{
...
...
@@ -161,10 +161,9 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
// Convert the full keys back to the cid.
$cid_results
=
array
();
foreach
(
$results
as
$value
)
{
if
(
is_object
(
$value
))
{
$cid_results
[
$value
->
cid
]
=
$value
;
}
$cid_lookup
=
array_flip
(
$full_keys
);
foreach
(
$results
as
$key
=>
$value
)
{
$cid_results
[
$cid_lookup
[
$key
]]
=
$value
;
}
return
$cid_results
;
}
...
...
memcache.inc
View file @
687433da
...
...
@@ -257,12 +257,11 @@ class MemCacheDrupal implements DrupalCacheInterface {
foreach
(
$this
->
wildcard_flushes
[
$this
->
bin
]
as
$flush_length
=>
$timestamp
)
{
if
(
$length
>=
$flush_length
&&
$timestamp
>=
(
$_SERVER
[
'REQUEST_TIME'
]
-
$this
->
invalidate
))
{
$key
=
'.wildcard-'
.
substr
(
$cid
,
0
,
$flush_length
);
$wildcard
=
dmemcache_key
(
$key
,
$this
->
bin
);
if
(
isset
(
$wildcards
[
$this
->
bin
][
$wildcard
]))
{
$matching
[
$wildcard
]
=
$wildcards
[
$this
->
bin
][
$wildcard
];
if
(
isset
(
$wildcards
[
$this
->
bin
][
$key
]))
{
$matching
[
$key
]
=
$wildcards
[
$this
->
bin
][
$key
];
}
else
{
$lookup
[
$
wildcard
]
=
$key
;
$lookup
[
$
key
]
=
$key
;
}
}
}
...
...
@@ -285,11 +284,12 @@ class MemCacheDrupal implements DrupalCacheInterface {
// Also store failed lookups in our static cache, so we don't have to
// do repeat lookups on single page loads.
foreach
(
$lookup
as
$
wildcard
=>
$key
)
{
$wildcards
[
$this
->
bin
][
$
wildcard
]
=
0
;
foreach
(
$lookup
as
$
key
=>
$key
)
{
$wildcards
[
$this
->
bin
][
$
key
]
=
0
;
}
}
}
if
(
$flush
)
{
// Avoid too many calls to variable_set() by only recording a flush for
// a fraction of the wildcard invalidation variable, per cid length.
...
...
@@ -301,14 +301,13 @@ class MemCacheDrupal implements DrupalCacheInterface {
$this
->
wildcard_flushes
[
$this
->
bin
][
$length
]
=
$_SERVER
[
'REQUEST_TIME'
];
variable_set
(
'memcache_wildcard_flushes'
,
$this
->
wildcard_flushes
);
}
$
wildcard
=
dmemcache_key
(
'.wildcard-'
.
$cid
,
$this
->
bin
)
;
if
(
isset
(
$wildcards
[
$this
->
bin
][
$
wildcard
])
&&
$wildcards
[
$this
->
bin
][
$wildcard
]
!=
0
)
{
$this
->
memcache
->
increment
(
$
wildcard
);
$wildcards
[
$this
->
bin
][
$
wildcard
]
++
;
$
key
=
'.wildcard-'
.
$cid
;
if
(
isset
(
$wildcards
[
$this
->
bin
][
$
key
])
&&
$wildcards
[
$this
->
bin
][
$key
]
!=
0
)
{
$this
->
memcache
->
increment
(
$
key
);
$wildcards
[
$this
->
bin
][
$
key
]
++
;
}
else
{
$wildcards
[
$this
->
bin
][
$wildcard
]
=
1
;
dmemcache_set
(
'.wildcard-'
.
$cid
,
'1'
,
0
,
$this
->
bin
);
dmemcache_set
(
$key
,
'1'
,
0
,
$this
->
bin
);
}
}
return
$matching
;
...
...
tests/memcache.test
View file @
687433da
...
...
@@ -363,27 +363,27 @@ class MemCacheClearCase extends MemcacheTestCase {
*/
function
clearWildcardPrefixTest
()
{
$this
->
resetVariables
();
cache_set
(
'test_cid_clear1'
,
$this
->
default_value
,
$this
->
default_bin
);
cache_set
(
'test_cid_clear2'
,
$this
->
default_value
,
$this
->
default_bin
);
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear1'
,
$this
->
default_value
)
&&
$this
->
checkCacheExists
(
'test_cid_clear2'
,
$this
->
default_value
),
cache_set
(
'test_cid_clear
:
1'
,
$this
->
default_value
,
$this
->
default_bin
);
cache_set
(
'test_cid_clear
:
2'
,
$this
->
default_value
,
$this
->
default_bin
);
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear
:
1'
,
$this
->
default_value
)
&&
$this
->
checkCacheExists
(
'test_cid_clear
:
2'
,
$this
->
default_value
),
t
(
'Two caches were created for checking cid substring with wildcard true.'
));
cache_clear_all
(
'test_'
,
$this
->
default_bin
,
TRUE
);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear1'
,
$this
->
default_value
)
||
$this
->
checkCacheExists
(
'test_cid_clear2'
,
$this
->
default_value
),
cache_clear_all
(
'test_
cid_clear:
'
,
$this
->
default_bin
,
TRUE
);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear
:
1'
,
$this
->
default_value
)
||
$this
->
checkCacheExists
(
'test_cid_clear
:
2'
,
$this
->
default_value
),
t
(
'Two caches removed after clearing cid substring with wildcard true.'
));
// Test for the case where a wildcard object disappears, for example a
// partial memcache restart or eviction.
cache_set
(
'test_cid_clear1'
,
$this
->
default_value
,
$this
->
default_bin
);
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear1'
,
$this
->
default_value
),
'The cache was created successfully.'
);
cache_set
(
'test_cid_clear
:
1'
,
$this
->
default_value
,
$this
->
default_bin
);
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear
:
1'
,
$this
->
default_value
),
'The cache was created successfully.'
);
cache_clear_all
(
'test_'
,
$this
->
default_bin
,
TRUE
);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear1'
,
$this
->
default_value
),
'The cache was cleared successfully.'
);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear
:
1'
,
$this
->
default_value
),
'The cache was cleared successfully.'
);
// Delete the wildcard manually to simulate an eviction.
$wildcard
=
'.wildcard-'
.
'test_'
;
$wildcard
=
'.wildcard-'
.
'test_
cid_clear:
'
;
dmemcache_delete
(
$wildcard
,
$this
->
default_bin
);
// Reset the memcache_wildcards() static cache.
// @todo: this is a class object in D7.
//memcache_wildcards(FALSE, FALSE, FALSE, TRUE);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear1'
,
$this
->
default_value
),
'The cache was cleared successfully.'
);
$this
->
assertFalse
(
$this
->
checkCacheExists
(
'test_cid_clear
:
1'
,
$this
->
default_value
),
'The cache was cleared successfully.'
);
}
}
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