-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '0.2.75' | ||
VERSION = '0.2.76' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import time | ||
import asyncio | ||
import random | ||
from lazyops.utils.helpers import timed_cache | ||
|
||
""" | ||
Test of the new behavior for only caching if the result is True | ||
""" | ||
|
||
_values = [ | ||
True, | ||
False, | ||
False, | ||
False, | ||
False, | ||
] | ||
|
||
@timed_cache(5, cache_if_result=True) | ||
def test_timed_cache() -> bool: | ||
return random.choice(_values) | ||
|
||
for _ in range(10): | ||
print(test_timed_cache()) | ||
|
||
@timed_cache(2, cache_if_result=True) | ||
async def test_timed_cache_async() -> bool: | ||
return random.choice(_values) | ||
|
||
|
||
async def run_test(): | ||
for _ in range(10): | ||
print(await test_timed_cache_async()) | ||
await asyncio.sleep(1) | ||
|
||
asyncio.run(run_test()) |