Ejemplo n.º 1
0
    def test_put(self):
        imc_1 = IMCache()
        imc_2 = IMCache()

        combined = CombinedCache(imc_1, imc_2)

        combined.put('a', 1)

        self.assertEqual(imc_1.get('a'), 1)
        self.assertEqual(imc_2.get('a'), 1)
Ejemplo n.º 2
0
    def test_multiget_update_closer_cache(self):
        imc_1 = IMCache()
        imc_2 = IMCache()

        combined = CombinedCache(imc_1, imc_2)

        imc_2.put('b', 1)

        with self.assertRaises(imc_1.CacheMissException):
            imc_1.get('b')

        self.assertEqual(combined.multiget(['b', 'c']), [1, None])
        self.assertEqual(imc_1.get('b'), 1)
Ejemplo n.º 3
0
    def test_multiget(self):
        imc_1 = IMCache()
        imc_2 = IMCache()
        imc_3 = IMCache()

        combined = CombinedCache(imc_1, imc_2, imc_3)

        imc_1.put('a', 1)
        imc_1.put('c', 3)
        imc_2.put('b', 2)
        imc_3.put('a', 4)
        imc_3.put('e', 5)

        self.assertEqual(combined.multiget(['a', 'b', 'c', 'd', 'e']), [1, 2, 3, None, 5])
Ejemplo n.º 4
0
    def test_get(self):
        imc_1 = IMCache()
        imc_2 = IMCache()

        combined = CombinedCache(imc_1, imc_2)

        imc_1.put('a', 1)
        self.assertEqual(combined.get('a'), 1)

        imc_2.put('b', 1)
        self.assertEqual(combined.get('b'), 1)

        imc_1.put('c', 1)
        imc_2.put('c', 2)
        self.assertEqual(combined.get('c'), 1)