PhpRedis.php 891 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * PhpRedis client specific implementation.
  4. */
  5. class Redis_Client_PhpRedis implements Redis_Client_FactoryInterface {
  6. public function getClient($options = array()) {
  7. $client = new Redis;
  8. if (!empty($options['socket'])) {
  9. $client->connect($options['socket']);
  10. } else {
  11. $client->connect($options['host'], $options['port']);
  12. }
  13. if (isset($options['password'])) {
  14. $client->auth($options['password']);
  15. }
  16. if (isset($options['base'])) {
  17. $client->select($options['base']);
  18. }
  19. // Do not allow PhpRedis serialize itself data, we are going to do it
  20. // ourself. This will ensure less memory footprint on Redis size when
  21. // we will attempt to store small values.
  22. $client->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
  23. return $client;
  24. }
  25. public function getName() {
  26. return 'PhpRedis';
  27. }
  28. }