-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can I instantiate Redis in CallbackqueryCommand.php... #61
Comments
@XiaomiYe Please add some code and more context, otherwise nobody can help 😊 |
/**
* Main command execution
* @return ServerResponse
* @throws \Exception
*/
public function execute(): ServerResponse
{
$callback_query = $this->getCallbackQuery();
$callback_data = $callback_query->getData();
$data['inline_message_id'] = $callback_query->getId();
//$callback_query->getInlineMessageId();
$data['keywords'] = $callback_data;
TelegramLog::debug(json_encode($data));
$redisobj = new Redis();
TelegramLog::debug("instantiate Redis");
try {
$connect = $redisobj->pconnect('127.0.0.1', 6379);
TelegramLog::debug(json_encode($connect));
} catch (Exception $e) {
TelegramLog::error(json_encode($e->getMessage()));
}
$redisobj->lpush('bot-list', $data);
return Request::emptyResponse();
} |
In your redis-cli you can use the
Your code should work, but you could try this:
$redisobj = new Redis();
TelegramLog::debug('instantiate Redis');
try {
$connect = $redisobj->connect('127.0.0.1', 6379);
TelegramLog::debug($connect);
$result = $redisobj->lPush('bot-list', $data);
TelegramLog::debug($result);
} catch (Exception $e) {
TelegramLog::error($e->getMessage());
} |
Thank you. I have found the problem and solved it |
Feel free to share the problem and your solution, so others (and me!) can learn, thanks 😃 |
just Replace with $redisobj=new \Redis(); |
I instantiate Redis in CallbackqueryCommand and want to write the data of CallbackqueryCommand into the list. But I don't know what went wrong
The text was updated successfully, but these errors were encountered: