php memcached客户端 - 设置数据时不起作用



我正在尝试php memcached客户端。看来,默认情况下,在PHP模因中进行设置操作。我尝试设置一个中等大的字符串数据,当我在telnet中运行get命令时,我获得的值仅以纯文本为单位。现在,当使用memcache完成相同的情况时,值是乱/难以辨认的。这不仅是我检查了Telnet中的统计数据。这是结果

memcache - compressed
bytes - 148
memcache - uncompressed
bytes - 285
memcached - uncompressed
bytes - 285
memcached - uncompressed
bytes - 285

您可以看到,使用PHP memcache使我的压缩为50%。因此,压缩确实有效。但是使用PHP备忘录,我没有压缩。即使我使用:

明确打开压缩,这也是如此
$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 );

我是否需要设置其他选项才能使此工作?自3周以来,我就从事这个项目了,如果压缩不起作用,我的老板将不接受从Memcache到Memcached的迁移。我希望您了解紧迫性;)(Kiddnig)。

版本:

memcached     - 1.4.5
php-memcached - 2.0.1
libmemcached  - 1.0.8

请帮助。

尝试设置memcached.compression_threshold in php.ini

memcached.compression_threshold = 100

然后设置值并使用telnet进行检查。

您的memcached.ini for参考

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"

最新更新