wa0x6e/php-resque-ex

workers do not work with memcache

sfai05 opened this issue · 5 comments

I am running in wordpress env. with memcache
However only the first task in worker can read/write into memcache
start from the second task memcache always return empty.

Any suggestion?

Maybe the memcached connection died ?

Can you try debugging by var_dump something, like the connection status ?

@Kamisama tried to initialize memcache on setUp()
didnt help

Do you have an example of job class ?

@sfai05 : You solved it. I'm facing with same problem. Please help me.
Thank you so much.

@duyquang1202 @wa0x6e was right. The memcached connection die after the first task in the worker is finished. You need to re-connect to memcache server in setUp

e.g.

public function setUp() {
    //reconnect memcache
    global $wp_object_cache;
    $m2 = new Memcached();
    $m2->addServers( array( array( '127.0.0.1', 11211 ) ) );
    $wp_object_cache->m = $m2;
}