Commits

Mike Bayer committed 699b0d7

The ``refresh()`` method on :meth:`.CacheRegion.get_or_create_multi`
now supports the ``asdict`` flag.

  • Participants
  • Parent commits b757812

Comments (0)

Files changed (3)

File docs/build/changelog.rst

 Changelog
 ==============
 .. changelog::
+    :version: 0.5.1
+
+    .. change::
+        :tags: bug
+
+      The ``refresh()`` method on :meth:`.CacheRegion.get_or_create_multi`
+      now supports the ``asdict`` flag.
+
+.. changelog::
     :version: 0.5.0
     :released: Fri Jun 21 2013
 

File dogpile/cache/region.py

             def refresh(*arg):
                 keys = key_generator(*arg)
                 values = fn(*arg)
-                self.set_multi(
-                            dict(zip(keys, values))
-                        )
-                return values
+                if asdict:
+                    self.set_multi(
+                                dict(zip(keys, [values[a] for a in arg]))
+                            )
+                    return values
+                else:
+                    self.set_multi(
+                                dict(zip(keys, values))
+                            )
+                    return values
 
             decorate.set = set_
             decorate.invalidate = invalidate

File tests/cache/test_decorator.py

         generate.set({7: 18, 10: 15})
         eq_(generate(2, 7, 10), {2: '2 5', 7: 18, 10: 15})
 
+        eq_(
+            generate.refresh(2, 7),
+            {2: '2 7', 7: '7 8'}
+        )
+        eq_(generate(2, 7, 10), {2: '2 7', 10: 15, 7: '7 8'})
+
+
     def test_multi_asdict_keys_missing(self):
         reg = self._region()