diff --git a/src/masonite/cache/drivers/FileDriver.py b/src/masonite/cache/drivers/FileDriver.py index 156343e6..4268f12b 100644 --- a/src/masonite/cache/drivers/FileDriver.py +++ b/src/masonite/cache/drivers/FileDriver.py @@ -70,6 +70,8 @@ def remember(self, key, callable): callable(self) + return self.get(key) + def forget(self, key): try: os.remove(os.path.join(self._get_directory(), key)) diff --git a/src/masonite/cache/drivers/MemcacheDriver.py b/src/masonite/cache/drivers/MemcacheDriver.py index ce21e234..2aa400b7 100644 --- a/src/masonite/cache/drivers/MemcacheDriver.py +++ b/src/masonite/cache/drivers/MemcacheDriver.py @@ -68,6 +68,8 @@ def remember(self, key, callable): callable(self) + return self.get(key) + def forget(self, key): return self.get_connection().delete(f"{self.get_name()}_cache_{key}") diff --git a/src/masonite/cache/drivers/RedisDriver.py b/src/masonite/cache/drivers/RedisDriver.py index ec208aa3..b49c18c0 100644 --- a/src/masonite/cache/drivers/RedisDriver.py +++ b/src/masonite/cache/drivers/RedisDriver.py @@ -123,6 +123,8 @@ def remember(self, key: str, callable): callable(self) + return self.get(key) + def forget(self, key: str) -> None: self.get_connection().delete(f"{self.get_cache_namespace()}{key}") self._internal_cache.pop(key) diff --git a/tests/features/cache/test_file_cache.py b/tests/features/cache/test_file_cache.py index adb30823..26a27781 100644 --- a/tests/features/cache/test_file_cache.py +++ b/tests/features/cache/test_file_cache.py @@ -42,8 +42,8 @@ def test_forget(self): self.assertEqual(self.driver.get("forget"), None) def test_remember(self): - self.driver.remember("remember", lambda cache: (cache.put("remember", "1", 10))) - self.assertEqual(self.driver.get("remember"), "1") + data_to_remember = self.driver.remember("remember", lambda cache: (cache.put("remember", "1", 10))) + self.assertEqual(data_to_remember, "1") def test_remember_datatypes(self): self.driver.remember( @@ -60,7 +60,7 @@ def test_flush(self): self.driver.flush() self.assertIsNone(self.driver.get("dic")) - def test_get_can_forget_expired(self): + def test_get_can_forget_expired(self): self.driver.put("forget_expired", "1", 1) time.sleep(1) self.assertEqual(self.driver.get("forget_expired"), None)