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


Python MemcachedClient.delete方法代码示例

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


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

示例1: storeJob

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import delete [as 别名]
def storeJob(jobDoc, bucket, first_pass = True):

    client = McdClient(HOST, PORT)
    client.sasl_auth_plain(bucket, "")

    doc = jobDoc
    url = doc["url"]

    res = getJS(url, {"depth" : 0}).json()

    if res is None:
        return

    buildHist = {}
    if res["lastBuild"]:

        bids = [b["number"] for b in res["builds"]]

        lastTotalCount = -1
        idx=0

        for bid in bids:
            idx = idx + 1
            i = 1
            if idx < len(bids):
                while bids[idx] != bid-i:
                    key = "%s-%s" % (doc["name"], bid-i)
                    key = hashlib.md5(key).hexdigest()
                    try:
                        client.delete(key, vbucket=0)
                    except:
                        pass
                    i = i + 1
            if bid in JOBS[doc["name"]]:
                continue # job already stored
            else:
                if first_pass == False:
                    JOBS[doc["name"]].append(bid)

            doc["build_id"] = bid
            res = getJS(url+str(bid), {"depth" : 0}).json()
            if res is None:
                return

            if "result" not in res:
                continue

            doc["result"] = res["result"]
            doc["duration"] = res["duration"]

            if bucket == "server":
                if res["result"] not in ["SUCCESS", "UNSTABLE", "FAILURE", "ABORTED"]:
                    continue # unknown result state

                actions = res["actions"]
                totalCount = getAction(actions, "totalCount") or 0
                failCount  = getAction(actions, "failCount") or 0
                skipCount  = getAction(actions, "skipCount") or 0
                if totalCount == 0:
                    if lastTotalCount == -1:
                        continue # no tests ever passed for this build
                    else:
                        totalCount = lastTotalCount
                        failCount = totalCount
                else:
                    lastTotalCount = totalCount

                doc["failCount"] = failCount
                doc["totalCount"] = totalCount - skipCount

                params = getAction(actions, "parameters")
                if params is None:
                    doc["priority"] = P1
                    doc["build"] = DEFAULT_BUILD
                else:
                    doc["build"] = getAction(params, "name", "version_number") or getAction(params, "name", "cluster_version") or  DEFAULT_BUILD
                    doc["priority"] = getAction(params, "name", "priority") or P1
                    if doc["priority"].upper() not in [P0, P1, P2]:
                        doc["priority"] = P1
                doc["build"] = doc["build"].replace("-rel","").split(",")[0]
                try:
                    _build= doc["build"].split("-")
                    rel, bno = _build[0], _build[1]
                    # check partial rel #'s
                    rlen = len(rel.split("."))
                    while rlen < 3:
                        rel = rel+".0"
                        rlen+=1

                    # verify rel, build
                    m=re.match("^\d\.\d\.\d{1,5}", rel)
                    if m is None:
                        print "unsupported version_number: "+doc["build"]
                        continue
                    m=re.match("^\d{1,10}", bno)
                    if m is None:
                        print "unsupported version_number: "+doc["build"]
                        continue

                    doc["build"] = "%s-%s" % (rel, bno.zfill(4))
#.........这里部分代码省略.........
开发者ID:subalakr,项目名称:jinja,代码行数:103,代码来源:jinja.py

示例2: int

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import delete [as 别名]
    number_of_items = int(options.items)

    mc = MemcachedClient("127.0.0.1", 11211)

    keys = ["{0}-{1}".format(prefix, i) for i in range(0, number_of_items)]
    info("inserting {0} items".format(number_of_items))
    for k in keys:
        mc.set(k, 0, 0, str(uuid.uuid4())[0:16])

    while True:
        info("now remove 3 chars from 80% of keys - if < 3 chars delete the key - if key does not exist create it")
        for i in range(0, 3):
            for k in keys:
                try:
                    a, b, value = mc.get(k)
                    if len(value) < 3:
                        mc.delete(k)
                    else:
                        mc.set(k, 0, 0, value[0:len(value) - 7])
                except:
                    mc.set(k, 0, 0, str(uuid.uuid4())[0:16])
            time.sleep(sleep_time)

        for k in keys:
            try:
                mc.prepend(k, "two")
            except:
                mc.set(k, 0, 0, str(uuid.uuid4())[0:16])

        time.sleep(sleep_time)
开发者ID:Boggypop,项目名称:testrunner,代码行数:32,代码来源:mb4461.py


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