本文整理汇总了Python中carbon.cache.MetricCache.store方法的典型用法代码示例。如果您正苦于以下问题:Python MetricCache.store方法的具体用法?Python MetricCache.store怎么用?Python MetricCache.store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类carbon.cache.MetricCache
的用法示例。
在下文中一共展示了MetricCache.store方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: backIntoCache
# 需要导入模块: from carbon.cache import MetricCache [as 别名]
# 或者: from carbon.cache.MetricCache import store [as 别名]
def backIntoCache(metricList):
for (metric, datapoints) in metricList:
for point in datapoints:
try:
MetricCache.store(metric, point)
except:
datapoints.append(point)
log.msg("Failed to publish to RabbitMQ. Pushed the metrics back to cache")
示例2: test_write_strategy_sorted
# 需要导入模块: from carbon.cache import MetricCache [as 别名]
# 或者: from carbon.cache.MetricCache import store [as 别名]
def test_write_strategy_sorted(self):
"""Create a metric cache, insert metrics, ensure sorted writes"""
self.assertEqual("sorted", MetricCache.method)
now = time.time()
datapoint1 = (now - 10, float(1))
datapoint2 = (now, float(2))
MetricCache.store("d.e.f", datapoint1)
MetricCache.store("a.b.c", datapoint1)
MetricCache.store("a.b.c", datapoint2)
(m, d) = MetricCache.pop()
self.assertEqual(("a.b.c", deque([datapoint1, datapoint2])), (m, d))
(m, d) = MetricCache.pop()
self.assertEqual(("d.e.f", deque([datapoint1])), (m, d))
self.assertEqual(0, MetricCache.size)
示例3: store
# 需要导入模块: from carbon.cache import MetricCache [as 别名]
# 或者: from carbon.cache.MetricCache import store [as 别名]
def store(metric, value):
fullMetric = 'carbon.agents.%s.%s' % (HOSTNAME, metric)
datapoint = (time.time(), value)
MetricCache.store(fullMetric, datapoint)