本文整理汇总了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));
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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
}
}
}
示例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;
}
示例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);
}
示例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));
}
}
}
示例9: uncacheClassName
protected function uncacheClassName($className, $idKeys)
{
foreach ($idKeys as $key) {
Cache::me()->mark($className)->delete($key);
}
}
示例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;
}
}
示例11: getCachedData
public function getCachedData($key)
{
return Cache::me()->mark($this->className)->get($this->makeDataKey($key, self::SUFFIX_QUERY));
}
示例12: cacheNullById
protected function cacheNullById($id)
{
return Cache::me()->mark($this->className)->add($this->makeIdKey($id), Cache::NOT_FOUND, Cache::EXPIRES_FOREVER);
}
示例13: drop
public function drop()
{
return Cache::me()->delete($this->index);
}
示例14: uncacheClassName
private function uncacheClassName($className)
{
if (!Cache::me()->mark($className)->increment($className, 1)) {
Cache::me()->mark($className)->delete($className);
}
}
示例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;
}