I was trying out php memcached client. It appears that compression is by default on for set operation in php memcached. I tried setting a moderately large string data and when I ran get command in the telnet, the value I got was in plain text only. Now when the same is done using memcache the value is garbled/illegible. It's not only that I checked the stats in telnet. Here are the results
memcache - compressed
bytes - 148
memcache - uncompressed
bytes - 285
memcached - uncompressed
bytes - 285
memcached - uncompressed
bytes - 285
As you can see, using php memcache got me a compression of 50%. So compression really worked. However using php memcached I got no compression. This is so even when I explicitly turned on the compression using:
$objMemcached->setOption(Memcached::OPT_COMPRESSION, true); //default fastlz compression
OR
$objMemcached->setOption(Memcached::OPT_COMPRESSION, true);
$objMemcached->setOption(Memcached::OPT_COMPRESSION_TYPE, Memcached::COMPRESSION_ZLIB );
Do I need to set any other option to get this working? I have been on this project since 3 weeks, if compression doesn't work my boss won't accept this migration from memcache to memcached. I hope you understand the urgency ;) (kiddnig).
Versions:
memcached - 1.4.5
php-memcached - 2.0.1
libmemcached - 1.0.8
Please help.
Your memcached.ini for reference
memcached.ini
; Enable PECL memcached extension module
extension = memcached.so
; Use memcached as a session handler
; valid values: files, memcached
; the default value is memcached
;session.save_handler = "memcached"
; Comma separated list of servers to use for session storage
;session.save_path = "127.0.0.1:11211"
[memcached]
; Use session locking
; valid values: On, Off
; the default value is On
memcached.sess_locking = On
; Session spin lock retry wait time in microseconds
; Be carefull when setting this value.
; valid values: integers, where 0 is interpreted as default
; Negative values result in a reduced locking to a try lock.
; the default value is 150000
memcached.sess_lock_wait = 150000
; Session key prefix
; valid values: strings less than 219 bytes long
; the default value is "memc.sess.key."
memcached.sess_prefix = "memc.sess.key."
; Session binary mode
memcached.sess_binary = Off
; Compression type
; valid values: fastlz, zlib
; the default value is fastlz
memcached.compression_type = "fastlz"
; Compression factor
; Store compressed value only if the compression
; factor (saving) exceeds the set limit.
; Store compressed if:
; plain_len > comp_len * factor
; the default value is 1.3 (23% space saving)
memcached.compression_factor = "1.3"
; Compression threshold
; Do not compress serialized values below this threshold.
; the default value is 2000 bytes
memcached.compression_threshold = 100
; Default serializer for new memcached objects
; valid values: php, igbinary, json, json_array
; json - standard php JSON encoding. This serializer
; is fast and compact but only works on UTF-8
; encoded data and does not fully implement
; serializing. See the JSON extension.
; json_array - as json, but decodes into arrays
; php - the standard php serializer
; igbinary - a binary serializer
; the default value is igbinary
;memcached.serializer = "igbinary"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With