You are here

abstract class Redis_AbstractBackend in Redis 7.3

Same name and namespace in other branches
  1. 7.2 lib/Redis/AbstractBackend.php \Redis_AbstractBackend

Hierarchy

Expanded class hierarchy of Redis_AbstractBackend

File

lib/Redis/AbstractBackend.php, line 3

View source
abstract class Redis_AbstractBackend implements Redis_BackendInterface {

  /**
   * Key components name separator
   */
  const KEY_SEPARATOR = ':';

  /**
   * @var string
   */
  private $prefix;

  /**
   * @var string
   */
  private $namespace;

  /**
   * @var mixed
   */
  private $client;

  /**
   * Default constructor
   *
   * @param mixed $client
   *   Redis client
   * @param string $namespace
   *   Component namespace
   * @param string $prefix
   *   Component prefix
   */
  public function __construct($client, $namespace = null, $prefix = null) {
    $this->client = $client;
    $this->prefix = $prefix;
    if (null !== $namespace) {
      $this->namespace = $namespace;
    }
  }
  public final function setClient($client) {
    $this->client = $client;
  }
  public final function getClient() {
    return $this->client;
  }
  public final function setPrefix($prefix) {
    $this->prefix = $prefix;
  }
  public final function getPrefix() {
    return $this->prefix;
  }
  public final function setNamespace($namespace) {
    $this->namespace = $namespace;
  }
  public final function getNamespace() {
    return $this->namespace;
  }

  /**
   * Get prefixed key
   *
   * @param string|string[] $parts
   *   Arbitrary number of strings to compose the key
   *
   * @return string
   */
  public function getKey($parts = array()) {
    $key = array();
    if (null !== $this->prefix) {
      $key[] = $this->prefix;
    }
    if (null !== $this->namespace) {
      $key[] = $this->namespace;
    }
    if ($parts) {
      if (is_array($parts)) {
        foreach ($parts as $part) {
          if ($part) {
            $key[] = $part;
          }
        }
      }
      else {
        $key[] = $parts;
      }
    }
    return implode(self::KEY_SEPARATOR, array_filter($key));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Redis_AbstractBackend::$client private property
Redis_AbstractBackend::$namespace private property
Redis_AbstractBackend::$prefix private property
Redis_AbstractBackend::getClient final public function Get client Overrides Redis_BackendInterface::getClient
Redis_AbstractBackend::getKey public function Get prefixed key Overrides Redis_BackendInterface::getKey 1
Redis_AbstractBackend::getNamespace final public function Get namespace Overrides Redis_BackendInterface::getNamespace
Redis_AbstractBackend::getPrefix final public function Get prefix Overrides Redis_BackendInterface::getPrefix
Redis_AbstractBackend::KEY_SEPARATOR constant Key components name separator
Redis_AbstractBackend::setClient final public function Set client Overrides Redis_BackendInterface::setClient
Redis_AbstractBackend::setNamespace final public function Set namespace Overrides Redis_BackendInterface::setNamespace
Redis_AbstractBackend::setPrefix final public function Set prefix Overrides Redis_BackendInterface::setPrefix
Redis_AbstractBackend::__construct public function Default constructor 1