Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
memcache
Commits
63bc6f2f
Commit
63bc6f2f
authored
Sep 19, 2011
by
Jeremy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#293902
by Jeremy: Improved admin statistics.
parent
687433da
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
429 additions
and
99 deletions
+429
-99
dmemcache.inc
dmemcache.inc
+57
-25
memcache.install
memcache.install
+5
-0
memcache_admin/memcache_admin.module
memcache_admin/memcache_admin.module
+367
-74
No files found.
dmemcache.inc
View file @
63bc6f2f
...
...
@@ -204,30 +204,62 @@ function dmemcache_flush($bin = 'cache', $mc = NULL) {
}
}
function
dmemcache_stats
(
$bin
=
'cache'
,
$type
=
''
)
{
// resolve requests for 'default' type to ''
if
(
$type
==
'default'
)
{
$type
=
''
;
}
// resolve requests for 'default' bin to 'cache'.
if
(
$bin
==
'default'
)
{
$bin
=
'cache'
;
}
if
(
$mc
=
dmemcache_object
(
$bin
))
{
if
(
$mc
instanceof
Memcached
)
{
return
$mc
->
getStats
();
}
// The PHP Memcache extension 3.x version throws an error if the stats
// type is NULL or not in {reset, malloc, slabs, cachedump, items, sizes}.
// If $type is 'default', then no parameter should be passed to the
// Memcache memcache_get_extended_stats() function.
if
(
$type
==
'default'
||
$type
==
''
)
{
return
$mc
->
getExtendedStats
();
function
dmemcache_stats
(
$stats_bin
=
'cache'
,
$stats_type
=
'default'
,
$aggregate
=
FALSE
)
{
$memcache_bins
=
variable_get
(
'memcache_bins'
,
array
(
'cache'
=>
'default'
));
// The stats_type can be over-loaded with an integer slab id, if doing a
// cachedump. We know we're doing a cachedump if $slab is non-zero.
$slab
=
(
int
)
$stats_type
;
foreach
(
$memcache_bins
as
$bin
=>
$target
)
{
if
(
$stats_bin
==
$bin
)
{
if
(
$mc
=
dmemcache_object
(
$bin
))
{
if
(
$mc
instanceof
Memcached
)
{
$stats
[
$bin
]
=
$mc
->
getStats
();
}
// The PHP Memcache extension 3.x version throws an error if the stats
// type is NULL or not in {reset, malloc, slabs, cachedump, items,
// sizes}. If $stats_type is 'default', then no parameter should be
// passed to the Memcache memcache_get_extended_stats() function.
else
if
(
$mc
instanceof
Memcache
)
{
if
(
$stats_type
==
'default'
||
$stats_type
==
''
)
{
$stats
[
$bin
]
=
$mc
->
getExtendedStats
();
}
// If $slab isn't zero, then we are dumping the contents of a
// specific cache slab.
else
if
(
!
empty
(
$slab
))
{
$stats
[
$bin
]
=
$mc
->
getStats
(
'cachedump'
,
$slab
);
}
else
{
$stats
[
$bin
]
=
$mc
->
getExtendedStats
(
$stats_type
);
}
}
}
}
else
{
return
$mc
->
getExtendedStats
(
$type
);
}
// Optionally calculate a sum-total for all servers in the current bin.
if
(
$aggregate
)
{
// Some variables don't logically aggregate.
$no_aggregate
=
array
(
'pid'
,
'time'
,
'version'
,
'pointer_size'
,
'accepting_conns'
,
'listen_disabled_num'
);
foreach
(
$stats
as
$bin
=>
$servers
)
{
if
(
is_array
(
$servers
))
{
foreach
(
$servers
as
$server
)
{
if
(
is_array
(
$server
))
{
foreach
(
$server
as
$key
=>
$value
)
{
if
(
!
in_array
(
$key
,
$no_aggregate
))
{
if
(
isset
(
$stats
[
$bin
][
'total'
][
$key
]))
{
$stats
[
$bin
][
'total'
][
$key
]
+=
$value
;
}
else
{
$stats
[
$bin
][
'total'
][
$key
]
=
$value
;
}
}
}
}
}
}
}
}
return
$stats
;
}
/**
...
...
@@ -310,6 +342,8 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
foreach
(
$default_opts
as
$key
=>
$value
)
{
$memcache
->
setOption
(
$key
,
$value
);
}
// See README.txt for setting custom Memcache options when using the
// memcached PECL extension.
$memconf
=
variable_get
(
'memcache_options'
,
array
());
foreach
(
$memconf
as
$key
=>
$value
)
{
$memcache
->
setOption
(
$key
,
$value
);
...
...
@@ -355,10 +389,8 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
$memcache
->
addServer
(
$host
,
$port
,
$memcache_persistent
);
}
}
else
{
if
(
$memcache
->
addServer
(
$host
,
$port
)
&&
!
$init
)
{
$init
=
TRUE
;
}
else
if
(
$memcache
->
addServer
(
$host
,
$port
)
&&
!
$init
)
{
$init
=
TRUE
;
}
}
}
...
...
memcache.install
View file @
63bc6f2f
...
...
@@ -43,3 +43,8 @@ function memcache_requirements($phase) {
}
return
$requirements
;
}
function
memcache_admin_update_7001
()
{
drupal_flush_all_caches
();
menu_rebuild
();
}
memcache_admin/memcache_admin.module
View file @
63bc6f2f
This diff is collapsed.
Click to expand it.
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