本文整理汇总了Python中point.util.redispool.RedisPool.decr方法的典型用法代码示例。如果您正苦于以下问题:Python RedisPool.decr方法的具体用法?Python RedisPool.decr怎么用?Python RedisPool.decr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类point.util.redispool.RedisPool
的用法示例。
在下文中一共展示了RedisPool.decr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from point.util.redispool import RedisPool [as 别名]
# 或者: from point.util.redispool.RedisPool import decr [as 别名]
def delete(self):
res = db.fetchone("DELETE FROM posts.comments "
"WHERE post_id=%s AND comment_id=%s "
"RETURNING files;",
[unb26(self.post.id), self.id])
if res and res['files']:
for f in res['files']:
remove_attach(f)
redis = RedisPool(settings.storage_socket)
redis.decr('cmnt_cnt.%s' % unb26(self.post.id))
示例2: delete
# 需要导入模块: from point.util.redispool import RedisPool [as 别名]
# 或者: from point.util.redispool.RedisPool import decr [as 别名]
def delete(self):
res = db.fetchone(
"DELETE FROM posts.comments " "WHERE post_id=%s AND comment_id=%s " "RETURNING files;",
[unb26(self.post.id), self.id],
)
if res and res["files"]:
for f in res["files"]:
remove_attach(f)
redis = RedisPool(settings.storage_socket)
redis.decr("cmnt_cnt.%s" % unb26(self.post.id))
try:
es = elasticsearch.Elasticsearch()
try:
es.delete(index="point-comments", doc_type="post", id="%s-%s" % (self.post.id, self.id))
except elasticsearch.exceptions.NotFoundError:
pass
except elasticsearch.ConnectionError, e:
log.error("Elasticsearch: %s" % e)
示例3: gen_invite
# 需要导入模块: from point.util.redispool import RedisPool [as 别名]
# 或者: from point.util.redispool.RedisPool import decr [as 别名]
def gen_invite():
redis = RedisPool(settings.storage_socket)
icnt = redis.decr('icnt:%s' % env.user.id)
if icnt < 0:
return 'Invitation limit exceeded'
key = sha1('%s%s' % (randint(1000000, 9999999),
datetime.now().isoformat())).hexdigest()
redis.set('invite:%s' % key, 1)
redis.expire('invite:%s' % key, 3600*48)
return key