コード例 #1
0
 /**
  * @since 2.4
  *
  * @param DIWikiPage $subject
  * @param DIProperty $property
  * @param RequestOptions|null $requestOptions
  *
  * @return array
  */
 public function getPropertyValues(DIWikiPage $subject, DIProperty $property, RequestOptions $requestOptions = null)
 {
     $key = $property->getKey() . ':' . $subject->getSubobjectName() . ':' . ($requestOptions !== null ? $requestOptions->getHash() : null);
     $container = $this->blobStore->read($this->getRootHashFrom($subject));
     if ($container->has($key)) {
         return $container->get($key);
     }
     $dataItems = $this->store->getPropertyValues($subject, $property, $requestOptions);
     $container->set($key, $dataItems);
     $this->blobStore->save($container);
     return $dataItems;
 }
コード例 #2
0
 public function testExpiry()
 {
     $blobStore = new BlobStore('Foo', $this->cache);
     $blobStore->setExpiryInSeconds(4);
     $container = $blobStore->read('bar');
     $container->set('one', 1001);
     $blobStore->save($container);
     $container = $blobStore->read('foo');
     $container->set('one', 42);
     $blobStore->save($container);
     $this->assertTrue($blobStore->exists('bar'));
     $this->assertTrue($blobStore->exists('foo'));
     sleep(5);
     $this->assertFalse($blobStore->exists('bar'));
     $this->assertFalse($blobStore->exists('foo'));
 }
コード例 #3
0
 private function appendToList($id, $subject)
 {
     // Store the id with the main subject
     $container = $this->blobStore->read($this->getHashFrom($subject));
     // Use the id as key to avoid unnecessary duplicate entries when
     // employing append
     $container->append('list', array($id => true));
     $this->blobStore->save($container);
 }
コード例 #4
0
 private function addToLinkedList($contextPage, $queryId)
 {
     // Ensure that without QueryDependencyLinksStore being enabled recorded
     // subjects related to a query can be discoverable and purged separately
     $container = $this->blobStore->read($this->getHashFrom($contextPage));
     // If a subject gets purged the the linked list of queries associated
     // with that subject allows for an immediate associated removal
     $container->addToLinkedList($this->getHashFrom($queryId));
     $this->blobStore->save($container);
 }
コード例 #5
0
 /**
  * @since 2.5
  */
 public function saveStats()
 {
     $container = $this->blobStore->read(md5($this->statsdId . self::VERSION));
     foreach ($this->stats as $key => $value) {
         $old = $container->has($key) ? $container->get($key) : 0;
         if ($this->operations[$key] === self::STATS_INIT && $old != 0) {
             $value = $old;
         }
         if ($this->operations[$key] === self::STATS_INCR) {
             $value = $old + $value;
         }
         // Use as-is
         // $this->operations[$key] === self::STATS_SET
         if ($this->operations[$key] === self::STATS_MEDIAN) {
             $value = $old > 0 ? ($old + $value) / 2 : $value;
         }
         $container->set($key, $value);
     }
     $this->blobStore->save($container);
     $this->stats = array();
 }
コード例 #6
0
ファイル: BlobStoreTest.php プロジェクト: Rikuforever/wiki
 public function testTransferExpiry()
 {
     $instance = new BlobStore('Foo', $this->cache);
     $instance->setExpiryInSeconds(42);
     $container = $instance->read('Bar');
     $this->assertEquals(42, $container->getExpiry());
 }