1. Mike Bayer
  2. dogpile.cache

Commits

Wichert Akkerman  committed b052a62

Handle empty multi get/set

This fixes #58

  • Participants
  • Parent commits 30685d0
  • Branches master

Comments (0)

Files changed (2)

File dogpile/cache/region.py

View file
         .. versionadded:: 0.5.0
 
         """
+        if not keys:
+            return []
+
         if self.key_mangler:
             keys = list(map(lambda key: self.key_mangler(key), keys))
 
         .. versionadded:: 0.5.0
 
         """
+        if not mapping:
+            return
 
         if self.key_mangler:
             mapping = dict((self.key_mangler(k), self._value(v))

File tests/cache/_fixtures.py

View file
         eq_(values['key2'], reg.get('key2'))
         eq_(values['key3'], reg.get('key3'))
 
+    def test_region_set_zero_multiple_values(self):
+        reg = self._region()
+        reg.set_multi({})
+
     def test_region_get_multiple_values(self):
         reg = self._region()
         key1 = 'value1'
             ]
         )
 
+    def test_region_get_empty_multiple(self):
+        reg = self._region()
+        reg_values = reg.get_multi([])
+        eq_(reg_values, [])
+
     def test_region_delete_multiple(self):
         reg = self._region()
         values = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}