pheanstalk and beanstalk functions

本秂侑毒 提交于 2019-11-28 02:18:00
Barmar
  1. You're correct that the spaces are insignificant. What you're seeing is called method chaining

$pheanstalk->useTube('testtube')->put("job payload goes here\n");

is equivalent to:

$temp = $pheanstalk->useTube('testtube');
$temp->put("job payload goes here\n");

So first it calls useTube() to specify which tube the payload should be put into, then it puts the payload into that. It's depending on the fact that methods that perform actions return the Pheanstalk object they were called on, so it's also short for:

$pheanstalk->useTube('testtube');
$pheanstalk->put("job payload goes here\n");
  1. ignore(tubename) removes that tube from the watchlist. The default tube is watched by default, so this disables that and just waits for messages in the testtube tube.

  2. It's doing exactly what the comment above it says: Checking that the server is available. You could use this in your producer code to report an error before trying to send to a beanstalk server that's not listening.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!