当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::me方法代码示例

本文整理汇总了PHP中Cache::me方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::me方法的具体用法?PHP Cache::me怎么用?PHP Cache::me使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


在下文中一共展示了Cache::me方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHstore

 /**
  * Install hstore
  * /usr/share/postgresql/contrib # cat hstore.sql | psql -U pgsql -d onphp
  **/
 public function testHstore()
 {
     foreach (DBTestPool::me()->getPool() as $connector => $db) {
         DBPool::me()->setDefault($db);
         $properties = array('age' => '23', 'weight' => 80, 'comment' => null);
         $user = TestUser::create()->setCity($moscow = TestCity::create()->setName('Moscow'))->setCredentials(Credentials::create()->setNickname('fake')->setPassword(sha1('passwd')))->setLastLogin(Timestamp::create(time()))->setRegistered(Timestamp::create(time())->modify('-1 day'))->setProperties(Hstore::make($properties));
         $moscow = TestCity::dao()->add($moscow);
         $user = TestUser::dao()->add($user);
         Cache::me()->clean();
         TestUser::dao()->dropIdentityMap();
         $user = TestUser::dao()->getById('1');
         $this->assertInstanceOf('Hstore', $user->getProperties());
         $this->assertEquals($properties, $user->getProperties()->getList());
         $form = TestUser::proto()->makeForm();
         $form->get('properties')->setFormMapping(array(Primitive::string('age'), Primitive::integer('weight'), Primitive::string('comment')));
         $form->import(array('id' => $user->getId()));
         $this->assertNotNull($form->getValue('id'));
         $object = $user;
         FormUtils::object2form($object, $form);
         $this->assertInstanceOf('Hstore', $form->getValue('properties'));
         $this->assertEquals(array_filter($properties), $form->getValue('properties')->getList());
         $subform = $form->get('properties')->getInnerForm();
         $this->assertEquals($subform->getValue('age'), '23');
         $this->assertEquals($subform->getValue('weight'), 80);
         $this->assertNull($subform->getValue('comment'));
         $user = new TestUser();
         FormUtils::form2object($form, $user, false);
         $this->assertEquals($user->getProperties()->getList(), array_filter($properties));
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:34,代码来源:HstoreDBTest.class.php

示例2: getLayerId

 protected function getLayerId()
 {
     if (!($result = Cache::me()->mark($this->className)->get($this->className))) {
         $result = mt_rand(1, self::MAX_RANDOM_ID);
         Cache::me()->mark($this->className)->set($this->className, $result, Cache::EXPIRES_FOREVER);
     }
     return '@' . $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:8,代码来源:CacheDaoWorker.class.php

示例3: testCriteria

 public function testCriteria()
 {
     foreach (DBTestPool::me()->getPool() as $db) {
         /* @var $db DB */
         DBPool::me()->setDefault($db);
         $this->getDBCreator()->fillDB();
         $queryResult = Criteria::create(TestCity::dao())->getResult();
         $this->assertEquals(2, $queryResult->getCount());
         Cache::me()->clean();
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:CriteriaDBTest.class.php

示例4: uncache

 public function uncache()
 {
     foreach ($this->classNameMap as $className => $uncaches) {
         list($idKeys, $tags, $worker) = $uncaches;
         /* @var $worker TaggableDaoWorker */
         $worker->expireTags($tags);
         foreach ($idKeys as $key) {
             Cache::me()->mark($className)->delete($idKey);
         }
         ClassUtils::callStaticMethod("{$className}::dao")->uncacheLists();
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:UncacherTaggableDaoWorker.class.php

示例5: testUnified

 public function testUnified()
 {
     foreach (DBTestPool::me()->getPool() as $db) {
         DBPool::me()->setDefault($db);
         $this->getDBCreator()->fillDB();
         $this->unified();
         Cache::me()->clean();
         TestUser::dao()->dropById(1);
         try {
             TestUser::dao()->dropByIds(array(1, 2));
             $this->fail();
         } catch (WrongStateException $e) {
             // ok
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:16,代码来源:CountAndUnifiedDBTest.class.php

示例6: uncacheClassName

 protected function uncacheClassName($className, $indexKey, $intKey)
 {
     $cache = Cache::me();
     $pool = SemaphorePool::me();
     if ($pool->get($intKey)) {
         $indexList = $cache->mark($className)->get($indexKey);
         $cache->mark($className)->delete($indexKey);
         if ($indexList) {
             foreach (array_keys($indexList) as $key) {
                 $cache->mark($className)->delete($key);
             }
         }
         $pool->free($intKey);
         return true;
     }
     $cache->mark($className)->delete($indexKey);
     return false;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:18,代码来源:UncacherSmartDaoWorkerLists.class.php

示例7: doTestMemcached

 private function doTestMemcached(SelectivePeer $cache)
 {
     Cache::setPeer($cache);
     if (!Cache::me()->isAlive()) {
         return $this->markTestSkipped('memcached not available');
     }
     for ($i = 0; $i < self::QUERIES; ++$i) {
         $this->assertTrue(Cache::me()->mark('one')->set($i, $i));
         $this->assertTrue(Cache::me()->mark('two')->set($i, $i));
     }
     $oneHit = 0;
     $twoHit = 0;
     for ($i = 0; $i < self::QUERIES; ++$i) {
         if (Cache::me()->mark('one')->get($i) == $i) {
             ++$oneHit;
         }
         if (Cache::me()->mark('two')->get($i) == $i) {
             ++$twoHit;
         }
     }
     $this->assertEquals($oneHit, $twoHit);
     $this->assertEquals($twoHit, self::QUERIES);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:23,代码来源:AggregateCacheTest.class.php

示例8: lazyTest

 private function lazyTest()
 {
     $city = TestCity::dao()->getById(1);
     $object = TestLazy::dao()->add(TestLazy::create()->setCity($city)->setCityOptional($city)->setEnum(new ImageType(ImageType::getAnyId())));
     Cache::me()->clean();
     $form = TestLazy::proto()->makeForm();
     $form->import(array('id' => $object->getId()));
     $this->assertNotNull($form->getValue('id'));
     FormUtils::object2form($object, $form);
     foreach ($object->proto()->getPropertyList() as $name => $property) {
         if ($property->getRelationId() == MetaRelation::ONE_TO_ONE && $property->getFetchStrategyId() == FetchStrategy::LAZY) {
             $this->assertEquals($object->{$property->getGetter()}(), $form->getValue($name));
         }
     }
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:15,代码来源:DAOTest.class.php

示例9: uncacheClassName

 protected function uncacheClassName($className, $idKeys)
 {
     foreach ($idKeys as $key) {
         Cache::me()->mark($className)->delete($key);
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:6,代码来源:UncacherBaseDaoWorker.class.php

示例10: gentlyGetByKey

 protected function gentlyGetByKey($key)
 {
     if ($this->handler->ping($this->keyToInt($key))) {
         return Cache::me()->mark($this->className)->get($key);
     } else {
         Cache::me()->mark($this->className)->delete($key);
         return null;
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:VoodooDaoWorker.class.php

示例11: getCachedData

 public function getCachedData($key)
 {
     return Cache::me()->mark($this->className)->get($this->makeDataKey($key, self::SUFFIX_QUERY));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:CustomDataScopedWorker.class.php

示例12: cacheNullById

 protected function cacheNullById($id)
 {
     return Cache::me()->mark($this->className)->add($this->makeIdKey($id), Cache::NOT_FOUND, Cache::EXPIRES_FOREVER);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:TransparentDaoWorker.class.php

示例13: drop

 public function drop()
 {
     return Cache::me()->delete($this->index);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:CacheSegmentHandler.class.php

示例14: uncacheClassName

 private function uncacheClassName($className)
 {
     if (!Cache::me()->mark($className)->increment($className, 1)) {
         Cache::me()->mark($className)->delete($className);
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:6,代码来源:UncacherCacheDaoWorkerLists.class.php

示例15: checkMap

 private function checkMap($objectKey)
 {
     $pool = SemaphorePool::me();
     $semKey = $this->keyToInt($this->indexKey);
     if (!$pool->get($semKey)) {
         return false;
     }
     if (!($map = Cache::me()->mark($this->className)->get($this->indexKey))) {
         $pool->free($semKey);
         return false;
     }
     if (!isset($map[$objectKey])) {
         $pool->free($semKey);
         return false;
     }
     $pool->free($semKey);
     return true;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:18,代码来源:SmartDaoWorker.class.php


注:本文中的Cache::me方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。