Fix #30: Provide RRCache.choice property.
diff --git a/CHANGES.rst b/CHANGES.rst
index feb677b..246f373 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,8 @@
1.0.0 UNRELEASED
----------------
+- Provide ``RRCache.choice`` property.
+
0.8.2 2014-12-15
----------------
diff --git a/cachetools/rr.py b/cachetools/rr.py
index 00c6f34..014caec 100644
--- a/cachetools/rr.py
+++ b/cachetools/rr.py
@@ -31,6 +31,11 @@
raise KeyError('cache is empty')
return (key, self.pop(key))
+ @property
+ def choice(self):
+ """Return the `choice` function used by the cache."""
+ return self.__choice
+
def rr_cache(maxsize=128, choice=random.choice, typed=False, getsizeof=None,
lock=RLock):
diff --git a/tests/test_rr.py b/tests/test_rr.py
index c35437c..7af9863 100644
--- a/tests/test_rr.py
+++ b/tests/test_rr.py
@@ -17,6 +17,7 @@
def test_choice(self):
cache = self.cache(maxsize=2, choice=min)
+ self.assertEqual(min, cache.choice)
cache[1] = 1
cache[2] = 2