add() public method

Add a to-be-resolved cache key.
public add ( string $unique, string $key )
$unique string
$key string
Example #1
0
 /**
  * @param string     $key
  * @param Repository $repository
  */
 public function __construct($key, Repository $repository)
 {
     $this->key = $key;
     /*
      * Register this key (tied to this particular object) to the value
      * repository.
      *
      * If 1 key is requested multiple times, the value could be an object
      * that could be altered (by reference) and if all objects-for-same-key
      * reference that same value, all would've been changed (because all
      * would be that exact same value.)
      *
      * I'm using spl_object_hash to get a unique identifier linking $key to
      * this particular object, without using this object itself (I could use
      * SplObjectStorage.) If I stored this object, it wouldn't be destructed
      * when it's no longer needed, and I want it to destruct so I can free
      * up this value in the repository when it's no longer needed.
      */
     $this->repository = $repository;
     $this->hash = spl_object_hash($this);
     $this->repository->add($this->hash, $this->key);
 }