ClientInterface.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis;
  11. use Predis\Command\CommandInterface;
  12. use Predis\Command\FactoryInterface;
  13. use Predis\Configuration\OptionsInterface;
  14. use Predis\Connection\ConnectionInterface;
  15. use Predis\Response\Status;
  16. /**
  17. * Interface defining a client able to execute commands against Redis.
  18. *
  19. * All the commands exposed by the client generally have the same signature as
  20. * described by the Redis documentation, but some of them offer an additional
  21. * and more friendly interface to ease programming which is described in the
  22. * following list of methods:
  23. *
  24. * @method int del(string[]|string $keyOrKeys, string ...$keys = null)
  25. * @method string|null dump(string $key)
  26. * @method int exists(string $key)
  27. * @method int expire(string $key, int $seconds)
  28. * @method int expireat(string $key, int $timestamp)
  29. * @method array keys(string $pattern)
  30. * @method int move(string $key, int $db)
  31. * @method mixed object($subcommand, string $key)
  32. * @method int persist(string $key)
  33. * @method int pexpire(string $key, int $milliseconds)
  34. * @method int pexpireat(string $key, int $timestamp)
  35. * @method int pttl(string $key)
  36. * @method string|null randomkey()
  37. * @method mixed rename(string $key, string $target)
  38. * @method int renamenx(string $key, string $target)
  39. * @method array scan($cursor, array $options = null)
  40. * @method array sort(string $key, array $options = null)
  41. * @method int ttl(string $key)
  42. * @method mixed type(string $key)
  43. * @method int append(string $key, $value)
  44. * @method int bitcount(string $key, $start = null, $end = null)
  45. * @method int bitop($operation, $destkey, $key)
  46. * @method array|null bitfield(string $key, $subcommand, ...$subcommandArg)
  47. * @method int bitpos(string $key, $bit, $start = null, $end = null)
  48. * @method int decr(string $key)
  49. * @method int decrby(string $key, int $decrement)
  50. * @method string|null get(string $key)
  51. * @method int getbit(string $key, $offset)
  52. * @method string getrange(string $key, $start, $end)
  53. * @method string|null getset(string $key, $value)
  54. * @method int incr(string $key)
  55. * @method int incrby(string $key, int $increment)
  56. * @method string incrbyfloat(string $key, int|float $increment)
  57. * @method array mget(string[]|string $keyOrKeys, string ...$keys = null)
  58. * @method mixed mset(array $dictionary)
  59. * @method int msetnx(array $dictionary)
  60. * @method Status psetex(string $key, $milliseconds, $value)
  61. * @method Status set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
  62. * @method int setbit(string $key, $offset, $value)
  63. * @method Status setex(string $key, $seconds, $value)
  64. * @method int setnx(string $key, $value)
  65. * @method int setrange(string $key, $offset, $value)
  66. * @method int strlen(string $key)
  67. * @method int hdel(string $key, array $fields)
  68. * @method int hexists(string $key, string $field)
  69. * @method string|null hget(string $key, string $field)
  70. * @method array hgetall(string $key)
  71. * @method int hincrby(string $key, string $field, int $increment)
  72. * @method string hincrbyfloat(string $key, string $field, int|float $increment)
  73. * @method array hkeys(string $key)
  74. * @method int hlen(string $key)
  75. * @method array hmget(string $key, array $fields)
  76. * @method mixed hmset(string $key, array $dictionary)
  77. * @method array hscan(string $key, $cursor, array $options = null)
  78. * @method int hset(string $key, string $field, string $value)
  79. * @method int hsetnx(string $key, string $field, string $value)
  80. * @method array hvals(string $key)
  81. * @method int hstrlen(string $key, string $field)
  82. * @method array|null blpop(array|string $keys, int|float $timeout)
  83. * @method array|null brpop(array|string $keys, int|float $timeout)
  84. * @method string|null brpoplpush(string $source, string $destination, int|float $timeout)
  85. * @method string|null lindex(string $key, int $index)
  86. * @method int linsert(string $key, $whence, $pivot, $value)
  87. * @method int llen(string $key)
  88. * @method string|null lpop(string $key)
  89. * @method int lpush(string $key, array $values)
  90. * @method int lpushx(string $key, array $values)
  91. * @method string[] lrange(string $key, int $start, int $stop)
  92. * @method int lrem(string $key, int $count, string $value)
  93. * @method mixed lset(string $key, int $index, string $value)
  94. * @method mixed ltrim(string $key, int $start, int $stop)
  95. * @method string|null rpop(string $key)
  96. * @method string|null rpoplpush(string $source, string $destination)
  97. * @method int rpush(string $key, array $values)
  98. * @method int rpushx(string $key, array $values)
  99. * @method int sadd(string $key, array $members)
  100. * @method int scard(string $key)
  101. * @method string[] sdiff(array|string $keys)
  102. * @method int sdiffstore(string $destination, array|string $keys)
  103. * @method string[] sinter(array|string $keys)
  104. * @method int sinterstore(string $destination, array|string $keys)
  105. * @method int sismember(string $key, string $member)
  106. * @method string[] smembers(string $key)
  107. * @method int smove(string $source, string $destination, string $member)
  108. * @method string|null spop(string $key, int $count = null)
  109. * @method string|null srandmember(string $key, int $count = null)
  110. * @method int srem(string $key, string $member)
  111. * @method array sscan(string $key, int $cursor, array $options = null)
  112. * @method string[] sunion(array|string $keys)
  113. * @method int sunionstore(string $destination, array|string $keys)
  114. * @method int touch(string[]|string $keyOrKeys, string ...$keys = null)
  115. * @method int zadd(string $key, array $membersAndScoresDictionary)
  116. * @method int zcard(string $key)
  117. * @method string zcount(string $key, int|string $min, int|string $max)
  118. * @method string zincrby(string $key, int $increment, string $member)
  119. * @method int zinterstore(string $destination, array|string $keys, array $options = null)
  120. * @method array zpopmin(string $key, int $count = 1)
  121. * @method array zpopmax(string $key, int $count = 1)
  122. * @method array zrange(string $key, int|string $start, int|string $stop, array $options = null)
  123. * @method array zrangebyscore(string $key, int|string $min, int|string $max, array $options = null)
  124. * @method int|null zrank(string $key, string $member)
  125. * @method int zrem(string $key, string ...$member)
  126. * @method int zremrangebyrank(string $key, int|string $start, int|string $stop)
  127. * @method int zremrangebyscore(string $key, int|string $min, int|string $max)
  128. * @method array zrevrange(string $key, int|string $start, int|string $stop, array $options = null)
  129. * @method array zrevrangebyscore(string $key, int|string $max, int|string $min, array $options = null)
  130. * @method int|null zrevrank(string $key, string $member)
  131. * @method int zunionstore(string $destination, array|string $keys, array $options = null)
  132. * @method string|null zscore(string $key, string $member)
  133. * @method array zscan(string $key, int $cursor, array $options = null)
  134. * @method array zrangebylex(string $key, string $start, string $stop, array $options = null)
  135. * @method array zrevrangebylex(string $key, string $start, string $stop, array $options = null)
  136. * @method int zremrangebylex(string $key, string $min, string $max)
  137. * @method int zlexcount(string $key, string $min, string $max)
  138. * @method int pfadd(string $key, array $elements)
  139. * @method mixed pfmerge(string $destinationKey, array|string $sourceKeys)
  140. * @method int pfcount(string[]|string $keyOrKeys, string ...$keys = null)
  141. * @method mixed pubsub($subcommand, $argument)
  142. * @method int publish($channel, $message)
  143. * @method mixed discard()
  144. * @method array|null exec()
  145. * @method mixed multi()
  146. * @method mixed unwatch()
  147. * @method mixed watch(string $key)
  148. * @method mixed eval(string $script, int $numkeys, string ...$keyOrArg = null)
  149. * @method mixed evalsha(string $script, int $numkeys, string ...$keyOrArg = null)
  150. * @method mixed script($subcommand, $argument = null)
  151. * @method mixed auth(string $password)
  152. * @method string echo(string $message)
  153. * @method mixed ping(string $message = null)
  154. * @method mixed select(int $database)
  155. * @method mixed bgrewriteaof()
  156. * @method mixed bgsave()
  157. * @method mixed client($subcommand, $argument = null)
  158. * @method mixed config($subcommand, $argument = null)
  159. * @method int dbsize()
  160. * @method mixed flushall()
  161. * @method mixed flushdb()
  162. * @method array info($section = null)
  163. * @method int lastsave()
  164. * @method mixed save()
  165. * @method mixed slaveof(string $host, int $port)
  166. * @method mixed slowlog($subcommand, $argument = null)
  167. * @method array time()
  168. * @method array command()
  169. * @method int geoadd(string $key, $longitude, $latitude, $member)
  170. * @method array geohash(string $key, array $members)
  171. * @method array geopos(string $key, array $members)
  172. * @method string|null geodist(string $key, $member1, $member2, $unit = null)
  173. * @method array georadius(string $key, $longitude, $latitude, $radius, $unit, array $options = null)
  174. * @method array georadiusbymember(string $key, $member, $radius, $unit, array $options = null)
  175. *
  176. * @author Daniele Alessandri <suppakilla@gmail.com>
  177. */
  178. interface ClientInterface
  179. {
  180. /**
  181. * Returns the command factory used by the client.
  182. *
  183. * @return FactoryInterface
  184. */
  185. public function getCommandFactory();
  186. /**
  187. * Returns the client options specified upon initialization.
  188. *
  189. * @return OptionsInterface
  190. */
  191. public function getOptions();
  192. /**
  193. * Opens the underlying connection to the server.
  194. */
  195. public function connect();
  196. /**
  197. * Closes the underlying connection from the server.
  198. */
  199. public function disconnect();
  200. /**
  201. * Returns the underlying connection instance.
  202. *
  203. * @return ConnectionInterface
  204. */
  205. public function getConnection();
  206. /**
  207. * Creates a new instance of the specified Redis command.
  208. *
  209. * @param string $method Command ID.
  210. * @param array $arguments Arguments for the command.
  211. *
  212. * @return CommandInterface
  213. */
  214. public function createCommand($method, $arguments = array());
  215. /**
  216. * Executes the specified Redis command.
  217. *
  218. * @param CommandInterface $command Command instance.
  219. *
  220. * @return mixed
  221. */
  222. public function executeCommand(CommandInterface $command);
  223. /**
  224. * Creates a Redis command with the specified arguments and sends a request
  225. * to the server.
  226. *
  227. * @param string $method Command ID.
  228. * @param array $arguments Arguments for the command.
  229. *
  230. * @return mixed
  231. */
  232. public function __call($method, $arguments);
  233. }