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
9cf27b7a
Commit
9cf27b7a
authored
Jan 15, 2017
by
Jeremy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2696129
by Jeremy: Add support for igbinary serialize/unserialize
parent
4ff14894
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
2 deletions
+71
-2
README.txt
README.txt
+35
-0
dmemcache.inc
dmemcache.inc
+17
-2
memcache_admin/memcache_admin.module
memcache_admin/memcache_admin.module
+19
-0
No files found.
README.txt
View file @
9cf27b7a
...
...
@@ -298,6 +298,41 @@ except for the 'cache_page' bin which will use the 'something_else_unique'
prefix. Not that if using a keyed array for specifying prefix, you must specify
the 'default' prefix.
## EXPERIMENTAL - ALTERNATIVE SERIALIZE: IGBINARY ##
This is a new experimental feature added to the memcache module in version
7.x-1.6 and should be tested carefully before utilizing in production.
To optimize how data is serialized before it is written to memcache, you can
enable the igbinary PHP extension which converts from using PHP's human
readable serialized data structures to a compact binary format. The igbinary
documentation claims on average a 50% reducation in storage requirements,
reducing the amount of traffic sent over the network. It goes on to explain:
"Unserialization performance is at least on par with the standard PHP
serializer. Serialization performance depends on the 'compact_strings'
option which enables duplicate string tracking. String are inserted to a
hash table which adds some overhead. In usual scenarios this does not have
much significance since usage pattern is 'serialize rarely, unserialize
often'. With 'compact_strings' option igbinary is usually a bit slower
than the standard serializer. Without it, a bit faster."
If the igbinary extension is enabled, the memcache modue will use it by
default. You can verify which serialize function is being used by enabling the
memcache_admin module and visiting admin/reports/memcache. To disable igbinary
when the php extension is installed add the following to your settings.php and
then restart all memcached daemons:
$conf['memcache_enable_igbinary'] = FALSE;
The project is maintained on GitHub:
- https://github.com/phadej/igbinary
The official PECL package can be found at:
- https://pecl.php.net/package/igbinary
Version 2.0.1 or greater is recommended.
## MAXIMUM LENGTHS ##
If the length of your prefix + key + bin combine to be more than 250 characters,
...
...
dmemcache.inc
View file @
9cf27b7a
...
...
@@ -149,7 +149,12 @@ function _dmemcache_set_pieces($key, $value, $exp = 0, $bin = 'cache', $mc = NUL
$serialized
=
FALSE
;
}
else
{
$data
=
serialize
(
$value
);
if
(
extension_loaded
(
'igbinary'
)
&&
variable_get
(
'memcache_enable_igbinary'
,
TRUE
))
{
$data
=
igbinary_serialize
(
$value
);
}
else
{
$data
=
serialize
(
$value
);
}
$serialized
=
TRUE
;
}
...
...
@@ -326,7 +331,17 @@ function _dmemcache_get_pieces($item, $key, $bin = 'cache', $mc = NULL) {
unset
(
$pieces
);
// If necessary unserialize the item.
return
empty
(
$item
->
serialized
)
?
$data
:
unserialize
(
$data
);
if
(
empty
(
$item
->
serialized
))
{
return
$data
;
}
else
{
if
(
extension_loaded
(
'igbinary'
)
&&
variable_get
(
'memcache_enable_igbinary'
,
TRUE
))
{
return
igbinary_unserialize
(
$data
);
}
else
{
return
unserialize
(
$data
);
}
}
}
/**
...
...
memcache_admin/memcache_admin.module
View file @
9cf27b7a
...
...
@@ -334,6 +334,25 @@ function memcache_admin_stats($bin = 'default') {
}
$report
[
'uptime'
][]
=
$item
;
// Report which serialize function is being used.
$item
=
array
(
'label'
=>
t
(
'Serialize function'
)
);
if
(
extension_loaded
(
'igbinary'
)
&&
variable_get
(
'memcache_enable_igbinary'
,
TRUE
))
{
$serialize_function
=
t
(
'igbinary_serialize v!version'
,
array
(
'!version'
=>
phpversion
(
'igbinary'
)));
}
else
{
$serialize_function
=
'serialize'
;
}
if
(
count
(
$aggregate
))
{
$report
[
'uptime'
][]
=
$item
;
$item
[
'servers'
]
=
$serialize_function
;
}
else
{
$item
[
'servers'
]
=
array
(
$servers
[
0
]
=>
$serialize_function
);
}
$report
[
'uptime'
][]
=
$item
;
// Report server time.
$item
=
array
(
'label'
=>
t
(
'Time'
),
...
...
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