示例#1
0
    def write(self):
        """
        Write a model to redis
        """

        dio_r = DataIORedis()
        dio_r.connect()

        # Write the model to redis
        if self.is_valid():
            return dio_r.write(key=self.genkey(),
                value=self.package())
        else:
            log.error('Invalid model -> "{0}"'.format(str(self._model)))
            return False
示例#2
0
    def test_simple(self):
        dior = DataIORedis()
        dior.connect()  # connect to local instance

        self.assertTrue(dior.write(key='try', value=1))
        self.assertTrue(dior.read(key='try') == 1)

        del dior
示例#3
0
    def test_init(self):
        dior = DataIORedis()
        dior.connect()  # connect to local instance

        del dior
示例#4
0
 def read(self, key):
     dio_r = DataIORedis()
     dio_r.connect()
     return dio_r.read(key=key)