本文整理汇总了Python中holmes.models.Page.get_page_count方法的典型用法代码示例。如果您正苦于以下问题:Python Page.get_page_count方法的具体用法?Python Page.get_page_count怎么用?Python Page.get_page_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holmes.models.Page
的用法示例。
在下文中一共展示了Page.get_page_count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_count
# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import get_page_count [as 别名]
def get_count(self, key, domain_name, expiration, get_count_method):
cache_key = '%s-%s' % (self.get_domain_name(domain_name), key)
count = self.redis.get(cache_key)
if count is not None:
return int(count)
domain = domain_name
if domain and not isinstance(domain, Domain):
domain = Domain.get_domain_by_name(domain_name, self.db)
if domain is None:
count = Page.get_page_count(self.db)
else:
count = get_count_method(domain)
cache_key = '%s-%s' % (self.get_domain_name(domain), key)
self.redis.setex(
cache_key,
expiration,
value=int(count)
)
return int(count)
示例2: handle
# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import get_page_count [as 别名]
def handle(has_key):
domain = domain_name
if domain and not isinstance(domain, Domain):
domain = Domain.get_domain_by_name(domain_name, self.db)
if has_key:
self.redis.incrby(key, increment, callback=callback)
else:
if domain is None:
value = Page.get_page_count(self.db) + increment - 1
else:
value = get_default_method(domain) + increment - 1
self.redis.set(key, value, callback=callback)
示例3: increment_count
# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import get_page_count [as 别名]
def increment_count(self, key, domain_name, get_default_method, increment=1):
key = '%s-%s' % (self.get_domain_name(domain_name), key)
has_key = self.has_key(key)
domain = domain_name
if domain and not isinstance(domain, Domain):
domain = Domain.get_domain_by_name(domain_name, self.db)
if has_key:
self.redis.incrby(key, increment)
else:
if domain is None:
value = Page.get_page_count(self.db) + increment - 1
else:
value = get_default_method(domain) + increment - 1
self.redis.set(key, value)
示例4: handle
# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import get_page_count [as 别名]
def handle(count):
if count is not None:
callback(int(count))
return
domain = self.get_domain(domain_name)
if domain is None:
count = Page.get_page_count(self.db)
else:
count = get_count_method(domain)
cache_key = '%s-%s' % (self.get_domain_name(domain), key)
self.redis.setex(
key=cache_key,
value=int(count),
seconds=expiration,
callback=self.handle_set_count(count, callback)
)