Example #1
0
def check_ttl(key, expected_ttl):
	"""
	Ensures that the given key has the given TTL.
	"""
	meta_key, meta_ttl, record = lib.read_record(lib.SET, key)
	lib.validate_record(key, record, [u"value"], [u"value"])
	lib.validate_meta(key, meta_key, meta_ttl, False, expected_ttl)
def check_bins(set_name, key, bin_names, value):
	"""
	Ensures that the given key has the given bins with the given value.
	"""
	meta_key, meta_ttl, record = lib.read_record(set_name, key)
	values = [value] * len(bin_names)
	lib.validate_record(key, record, bin_names, values)
	lib.validate_meta(key, meta_key, meta_ttl)
def check_values(set_name, key, values):
	"""
	Ensures that the given key has bins "bin-0" ... "bin-<n>" with the n given values.
	"""
	meta_key, meta_ttl, record = lib.read_record(set_name, key)
	bin_names = [u"bin-" + str(index) for index in xrange(len(values))]
	lib.validate_record(key, record, bin_names, values)
	lib.validate_meta(key, meta_key, meta_ttl)
Example #4
0
def check_values(set_name, key, values):
	"""
	Ensures that the given key has bins "bin-0" ... "bin-<n>" with the n given values.
	"""
	meta_key, meta_ttl, record = lib.read_record(set_name, key)
	bin_names = [u"bin-" + str(index) for index in xrange(len(values))]
	lib.validate_record(key, record, bin_names, values)
	lib.validate_meta(key, meta_key, meta_ttl)
def check_bins(set_name, key, bin_names, value):
    """
	Ensures that the given key has the given bins with the given value.
	"""
    meta_key, meta_ttl, record = lib.read_record(set_name, key)
    values = [value] * len(bin_names)
    lib.validate_record(key, record, bin_names, values)
    lib.validate_meta(key, meta_key, meta_ttl)
def check_sets(set_names, key, bin_name, value):
	"""
	Ensures that the given key has the given bin with the given value
	across all given sets.
	"""
	for set_name in set_names:
		meta_key, meta_ttl, record = lib.read_record(set_name, key)
		lib.validate_record(key, record, [bin_name], [value])
		lib.validate_meta(key, meta_key, meta_ttl)
Example #7
0
def check_sets(set_names, key, bin_name, value):
    """
	Ensures that the given key has the given bin with the given value
	across all given sets.
	"""
    for set_name in set_names:
        meta_key, meta_ttl, record = lib.read_record(set_name, key)
        lib.validate_record(key, record, [bin_name], [value])
        lib.validate_meta(key, meta_key, meta_ttl)
def check_keys(set_name, keys, value, expect_key):
	"""
	Ensures that the given keys have a single "value" bin with the given value.

	We use a scan here, so that we can honor the expect_key flag. A get operation
	wouldn't allow us to determine whether a record in the database has a user key
	or not.
	"""
	records = lib.read_all_records(set_name)

	for key in keys:
		digest = lib.get_key_digest(set_name, key)
		meta_key, meta_ttl, record = records[str(digest).encode("hex")]
		lib.validate_record(key, record, [u"value"], [value])
		lib.validate_meta(key, meta_key, meta_ttl, expect_key)
def check_keys(set_name, keys, value, expect_key):
    """
	Ensures that the given keys have a single "value" bin with the given value.

	We use a scan here, so that we can honor the expect_key flag. A get operation
	wouldn't allow us to determine whether a record in the database has a user key
	or not.
	"""
    records = lib.read_all_records(set_name)

    for key in keys:
        digest = lib.get_key_digest(set_name, key)
        meta_key, meta_ttl, record = records[str(digest).encode("hex")]
        lib.validate_record(key, record, [u"value"], [value])
        lib.validate_meta(key, meta_key, meta_ttl, expect_key)