class Server extends Server (View source)

Constants

ERROR

To return an ERR reply from the Redis server.

NIL

To return a NULL reply from the Redis server.

When used as the 1st parameter "$type" in method \Swoole\Redis\Server::format(), there is no need to pass in the 2nd parameter "$value".

STATUS

To return a Status reply from the Redis server.

INT

To return an Integer reply from the Redis server.

When used as the 1st parameter "$type" in method \Swoole\Redis\Server::format(), the 2nd parameter "$value" must be an integer.

STRING

To return a String reply from the Redis server.

When used as the 1st parameter "$type" in method \Swoole\Redis\Server::format(), the 2nd parameter "$value" must be a string.

SET

To return a Set reply from the Redis server.

When used as the 1st parameter "$type" in method \Swoole\Redis\Server::format(), the 2nd parameter "$value" must be an array.

MAP

To return a Map reply from the Redis server.

When used as the 1st parameter "$type" in method \Swoole\Redis\Server::format(), the 2nd parameter "$value" must be an associative array.

Properties

$setting from  Server
$connections from  Server
$host from  Server
$port from  Server
$type from  Server
$mode from  Server
$ports from  Server
$master_pid from  Server
$manager_pid from  Server
$worker_id from  Server
$taskworker from  Server
$worker_pid from  Server
$stats_timer from  Server
Server Since: 4.8.0
$admin_server from  Server

Methods

__construct($host, $port = null, $mode = null, $sock_type = null)

No description

from  Server
__destruct()

No description

from  Server
mixed
listen(mixed $host, mixed $port, mixed $sock_type)

No description

from  Server
mixed
addlistener(mixed $host, mixed $port, mixed $sock_type)

No description

from  Server
mixed
on(mixed $event_name, callable $callback)

No description

from  Server
mixed
getCallback(mixed $event_name)

No description

from  Server
mixed
set(array $settings)

No description

from  Server
mixed
start()

No description

from  Server
mixed
send(mixed $fd, mixed $send_data, mixed|null $server_socket = null)

No description

from  Server
mixed
sendto(mixed $ip, mixed $port, mixed $send_data, mixed|null $server_socket = null)

No description

from  Server
mixed
sendwait(mixed $conn_fd, mixed $send_data)

No description

from  Server
mixed
exists(mixed $fd)

No description

from  Server
mixed
exist(mixed $fd)

No description

from  Server
mixed
protect(mixed $fd, mixed|null $is_protected = null)

No description

from  Server
mixed
sendfile(mixed $conn_fd, mixed $filename, mixed|null $offset = null, mixed|null $length = null)

No description

from  Server
mixed
close(mixed $fd, mixed|null $reset = null)

No description

from  Server
mixed
confirm(mixed $fd)

No description

from  Server
mixed
pause(mixed $fd)

No description

from  Server
mixed
resume(mixed $fd)

No description

from  Server
mixed
task(mixed $data, mixed|null $worker_id = null, callable|null $finish_callback = null)

No description

from  Server
mixed
taskwait(mixed $data, mixed|null $timeout = null, mixed|null $worker_id = null)

No description

from  Server
mixed
taskWaitMulti(array $tasks, mixed|null $timeout = null)

No description

from  Server
mixed
taskCo(array $tasks, mixed|null $timeout = null)

No description

from  Server
mixed
finish(mixed $data)

No description

from  Server
mixed
reload()

No description

from  Server
mixed
shutdown()

No description

from  Server
mixed
stop(mixed|null $worker_id = null)

No description

from  Server
mixed
getLastError()

No description

from  Server
mixed
heartbeat(mixed $reactor_id)

No description

from  Server
mixed
getClientInfo(mixed $fd, mixed|null $reactor_id = null)

No description

from  Server
mixed
getClientList(mixed $start_fd, mixed|null $find_count = null)

No description

from  Server
int|false
getWorkerId()

Get the ID of current worker (either an event worker or a task worker).

from  Server
int|false
getWorkerPid(int $worker_id = -1)

Get the process ID of a given worker process (specified by a worker ID).

from  Server
mixed
getWorkerStatus(mixed|null $worker_id = null)

No description

from  Server
mixed|false
command(string $name, int $process_id, int $process_type, mixed $data, bool $json_decode = true)

Run a customized command in a specified process of Swoole.

from  Server
bool
addCommand(string $name, int $accepted_process_types, callable $callback)

Add a customized command.

from  Server
mixed
getManagerPid()

No description

from  Server
mixed
getMasterPid()

No description

from  Server
mixed
connection_info(mixed $fd, mixed|null $reactor_id = null)

No description

from  Server
mixed
connection_list(mixed $start_fd, mixed|null $find_count = null)

No description

from  Server
mixed
sendMessage(mixed $message, mixed $dst_worker_id)

No description

from  Server
int|false
addProcess(Process $process)

No description

from  Server
mixed
stats()

No description

from  Server
mixed
getSocket(mixed|null $port = null)

No description

from  Server
mixed
bind(mixed $fd, mixed $uid)

No description

from  Server
int
after(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::after().

from  Server
int
tick(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::tick().

from  Server
bool
clearTimer(int $timer_id)

Alias of method \Swoole\Timer::clear().

from  Server
true
defer(callable $callback)

Alias of method \Swoole\Event::defer().

from  Server
bool
setHandler(string $command, callable $callback)

Set a handler (a callback function) to process a given Redis command.

callable|null
getHandler(string $command)

No description

static string|false
format(int $type, mixed|null $value = null)

Format a reply.

Details

__construct($host, $port = null, $mode = null, $sock_type = null)

No description

Parameters

$host
$port
$mode
$sock_type

__destruct()

No description

mixed listen(mixed $host, mixed $port, mixed $sock_type)

No description

Parameters

mixed $host
mixed $port
mixed $sock_type

Return Value

mixed

mixed addlistener(mixed $host, mixed $port, mixed $sock_type)

No description

Parameters

mixed $host
mixed $port
mixed $sock_type

Return Value

mixed

mixed on(mixed $event_name, callable $callback)

No description

Parameters

mixed $event_name
callable $callback

Return Value

mixed

mixed getCallback(mixed $event_name)

No description

Parameters

mixed $event_name

Return Value

mixed

mixed set(array $settings)

No description

Parameters

array $settings

Return Value

mixed

mixed start()

No description

Return Value

mixed

mixed send(mixed $fd, mixed $send_data, mixed|null $server_socket = null)

No description

Parameters

mixed $fd
mixed $send_data
mixed|null $server_socket

Return Value

mixed

mixed sendto(mixed $ip, mixed $port, mixed $send_data, mixed|null $server_socket = null)

No description

Parameters

mixed $ip
mixed $port
mixed $send_data
mixed|null $server_socket

Return Value

mixed

mixed sendwait(mixed $conn_fd, mixed $send_data)

No description

Parameters

mixed $conn_fd
mixed $send_data

Return Value

mixed

mixed exists(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed exist(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed protect(mixed $fd, mixed|null $is_protected = null)

No description

Parameters

mixed $fd
mixed|null $is_protected

Return Value

mixed

mixed sendfile(mixed $conn_fd, mixed $filename, mixed|null $offset = null, mixed|null $length = null)

No description

Parameters

mixed $conn_fd
mixed $filename
mixed|null $offset
mixed|null $length

Return Value

mixed

mixed close(mixed $fd, mixed|null $reset = null)

No description

Parameters

mixed $fd
mixed|null $reset

Return Value

mixed

mixed confirm(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed pause(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed resume(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed task(mixed $data, mixed|null $worker_id = null, callable|null $finish_callback = null)

No description

Parameters

mixed $data
mixed|null $worker_id
callable|null $finish_callback

Return Value

mixed

mixed taskwait(mixed $data, mixed|null $timeout = null, mixed|null $worker_id = null)

No description

Parameters

mixed $data
mixed|null $timeout
mixed|null $worker_id

Return Value

mixed

mixed taskWaitMulti(array $tasks, mixed|null $timeout = null)

No description

Parameters

array $tasks
mixed|null $timeout

Return Value

mixed

mixed taskCo(array $tasks, mixed|null $timeout = null)

No description

Parameters

array $tasks
mixed|null $timeout

Return Value

mixed

mixed finish(mixed $data)

No description

Parameters

mixed $data

Return Value

mixed

mixed reload()

No description

Return Value

mixed

mixed shutdown()

No description

Return Value

mixed

mixed stop(mixed|null $worker_id = null)

No description

Parameters

mixed|null $worker_id

Return Value

mixed

mixed getLastError()

No description

Return Value

mixed

mixed heartbeat(mixed $reactor_id)

No description

Parameters

mixed $reactor_id

Return Value

mixed

mixed getClientInfo(mixed $fd, mixed|null $reactor_id = null)

No description

Parameters

mixed $fd
mixed|null $reactor_id

Return Value

mixed

mixed getClientList(mixed $start_fd, mixed|null $find_count = null)

No description

Parameters

mixed $start_fd
mixed|null $find_count

Return Value

mixed

int|false getWorkerId()

Get the ID of current worker (either an event worker or a task worker).

Return Value

int|false

Returns the ID of current worker. Returns false if not called within a worker process (either an event worker process or a task worker process).

int|false getWorkerPid(int $worker_id = -1)

Get the process ID of a given worker process (specified by a worker ID).

Parameters

int $worker_id

Return Value

int|false

Returns the process ID of a given worker process (specified by a worker ID). If the worker ID is a negative integer or not passed in, returns the process ID of current worker process. Returns false if something wrong happens (e.g., the worker process doesn't exist, or an invalid worker ID specified.).

mixed getWorkerStatus(mixed|null $worker_id = null)

No description

Parameters

mixed|null $worker_id

Return Value

mixed

mixed|false command(string $name, int $process_id, int $process_type, mixed $data, bool $json_decode = true)

Since: 4.8.0

Run a customized command in a specified process of Swoole.

Parameters

string $name
int $process_id
int $process_type
mixed $data
bool $json_decode

Return Value

mixed|false

See also

Server::addCommand

bool addCommand(string $name, int $accepted_process_types, callable $callback)

Since: 4.8.0

Add a customized command.

Commands can be added to the master process, the manager process, or worker processes. Commands can only be added before the server is started.

Parameters

string $name
int $accepted_process_types

One or multiple types of processes. e.g., "SWOOLE_SERVER_COMMAND_EVENT_WORKER | SWOOLE_SERVER_COMMAND_TASK_WORKER".

callable $callback

The callback function should return a (serialized) string back.

Return Value

bool

TRUE if succeeds, otherwise FALSE.

See also

Server::command
SWOOLE_SERVER_COMMAND_MASTER
SWOOLE_SERVER_COMMAND_MANAGER
SWOOLE_SERVER_COMMAND_EVENT_WORKER
SWOOLE_SERVER_COMMAND_TASK_WORKER

mixed getManagerPid()

No description

Return Value

mixed

mixed getMasterPid()

No description

Return Value

mixed

mixed connection_info(mixed $fd, mixed|null $reactor_id = null)

No description

Parameters

mixed $fd
mixed|null $reactor_id

Return Value

mixed

mixed connection_list(mixed $start_fd, mixed|null $find_count = null)

No description

Parameters

mixed $start_fd
mixed|null $find_count

Return Value

mixed

mixed sendMessage(mixed $message, mixed $dst_worker_id)

No description

Parameters

mixed $message
mixed $dst_worker_id

Return Value

mixed

int|false addProcess(Process $process)

No description

Parameters

Process $process

Return Value

int|false

Return the ID of the process (\Swoole\Process::$id) back if succeeds; otherwise return FALSE.

See also

Process::$id

mixed stats()

No description

Return Value

mixed

mixed getSocket(mixed|null $port = null)

No description

Parameters

mixed|null $port

Return Value

mixed

mixed bind(mixed $fd, mixed $uid)

No description

Parameters

mixed $fd
mixed $uid

Return Value

mixed

int after(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::after().

Parameters

int $ms
callable $callback
...$params

Return Value

int

See also

Timer::after

int tick(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::tick().

Parameters

int $ms
callable $callback
...$params

Return Value

int

See also

Timer::tick

bool clearTimer(int $timer_id)

Alias of method \Swoole\Timer::clear().

Parameters

int $timer_id

Return Value

bool

See also

Timer::clear

true defer(callable $callback)

Alias of method \Swoole\Event::defer().

Parameters

callable $callback

Return Value

true

See also

Event::defer

bool setHandler(string $command, callable $callback)

Set a handler (a callback function) to process a given Redis command.

Parameters

string $command
callable $callback

Return Value

bool

TRUE on success, or FALSE on failure.

callable|null getHandler(string $command)

No description

Parameters

string $command

Return Value

callable|null

Returns the callback function if defined, otherwise NULL.

static string|false format(int $type, mixed|null $value = null)

Format a reply.

Parameters

int $type
mixed|null $value

Return Value

string|false