21 lines
405 B
Python
21 lines
405 B
Python
from uncloud.common.shared import shared
|
|
|
|
|
|
def increment_etcd_counter(key):
|
|
kv = shared.etcd_client.get(key)
|
|
|
|
if kv:
|
|
counter = int(kv.value)
|
|
counter = counter + 1
|
|
else:
|
|
counter = 1
|
|
|
|
shared.etcd_client.put(key, str(counter))
|
|
return counter
|
|
|
|
|
|
def get_etcd_counter(key):
|
|
kv = shared.etcd_client.get(key)
|
|
if kv:
|
|
return int(kv.value)
|
|
return None
|