地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

【Redis】pythonでパイプラインする

github.com

r = redis.Redis()
p = r.pipeline()
p.set("transError", var)
p.execute()

測定プログラム

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals

import redis
import time

r = redis.StrictRedis(host='localhost', port=6379, db=0)

# 通常の場合
start = time.time()
for key in range(1000):
    r.get(key)
stop = time.time()
print stop - start

# パイプライニングした場合
start = time.time()
with r.pipeline() as pipe:
    for key in range(1000):
        pipe.get(key)
    pipe.execute()
stop = time.time()
print stop - start

【k8s】conftestのメモ

conftestはyamlに限らないポリシーチェックツール。rego言語を使ってポリシーを書く。この記事では便利なサイトとかをまとめて貼っておく。

playground

play.openpolicyagent.org

手元に実行環境がないのでwebでさくっと試せる。regoを学ぶのに良さそう。

公式

www.openpolicyagent.org

日本語情報がほぼほぼないので公式が唯一ぐらいの情報源。

conftest GitHub

github.com

gatekeeperとかいれてもいいけど手を動かす量が半端ないのでこっちで。CI組み込みとかもさくっとできるので便利