Change serialization functions in PHP for Memcached

后端 未结 2 2065
长情又很酷
长情又很酷 2021-01-16 10:54

By default Memcached module in PHP uses PHP\'s built in serialization functions. Because I\'m accesing the same keys from other programming languages, I have found a seriali

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-16 11:09

    If your memcached php module has been compiled with HAVE_JSON_API defined (which I think is true by default since php 5.2. Documentation says "Requires PHP 5.2.10+") you can set the JSON serializer with

    $memchache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_JSON);
    

    (and there are json en-/decoders for many, many languages)

    see http://docs.php.net/memcached.constants

提交回复
热议问题