ClientInterface.php 8.4 KB

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