targets = new HashBagOStuff( array( 'maxKeys' => self::TARGET_MAX_NUM ) ); } /** * Add a key to the lookup and the key is used to resolve cache target * * @param int $key */ public function add( $key, $target = null ) { if ( count( $this->lookups ) < self::TARGET_MAX_NUM && !$this->targets->get( $key ) ) { $this->lookups[$key] = $key; } } /** * Get the cache target based on the key * * @param int $key * @return mixed|null */ public function get( $key ) { $target = $this->targets->get( $key ); if ( $target ) { return $target; } if ( isset( $this->lookups[$key] ) ) { $this->resolve(); $target = $this->targets->get( $key ); if ( $target ) { return $target; } } return null; } /** * Clear everything in local cache */ public function clearAll() { $this->targets->clear(); $this->lookups = array(); } /** * @return int[] */ public function getLookups() { return $this->lookups; } /** * @return BagOStuff */ public function getTargets() { return $this->targets; } }