Пример #1
0
    def test_service(self):
        s = Service()

        s.set("wenbinhuang", "liu")
        res = s.get("wenbinhuang")
        print(res)
        self.assertEqual(res == "liu", True)

        s.delete("wenbinhuang")

        self.assertEqual(s.get("wenbinhuang") == None, True)
Пример #2
0
class SimKV():
    def __init__(self, directory_name):
        if os.path.exists(directory_name) == False:
            os.mkdir(directory_name)
        self.directory_name = directory_name
        self.service = Service(directory_name)

    def open(self, directory_name):
        handler = SimKV(directory_name)
        return handler

    def set(self, key, value):
        return self.service.set(key, value)

    def get(self, key):
        return self.service.get(key)

    def delete(self, key):
        return self.service.delete(key)

    def merge(self):
        return self.service.merge()

    def close(self):
        self.service.close()