(20260109) Almost done with Cosec-TCAOFF sync.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import time
|
||||
from utils_v2.system import files
|
||||
from utils_v2.cache_v2.async_mem_cache import AsyncMemCache
|
||||
from utils_v2.cache_v2.async_disk_cache import AsyncDiskCache
|
||||
import asyncio
|
||||
|
||||
async def main():
|
||||
|
||||
proj_dir = files.get_file_directory(include_filename = False)
|
||||
proj_dir = files.get_parent_directory(proj_dir, depth = 1)
|
||||
print("PROJ. DIR.:", proj_dir)
|
||||
|
||||
memcache = AsyncMemCache()
|
||||
# diskcache = AsyncDiskCache(
|
||||
# caching_dir = os.path.join(proj_dir, "local"),
|
||||
# lock_on_read = False,
|
||||
# lock_wait_timeout = 5.0,
|
||||
# expiry_check_interval = 60.0
|
||||
# )
|
||||
|
||||
cache = memcache
|
||||
|
||||
# print("\n\n---\n\n")
|
||||
# print("EXPIRY CHECK:")
|
||||
# await cache.set("k1", "v1", expiry = 3.0)
|
||||
# print(await cache.get("k1"))
|
||||
# time.sleep(3.1)
|
||||
# print(await cache.get("k1"))
|
||||
|
||||
print("\n\n---\n\n")
|
||||
print("DELETE CHECK:")
|
||||
await cache.set("k1", "v1", expiry = 30.0)
|
||||
await cache.set("k2", "v2", expiry = 30.0)
|
||||
await cache.set("k3", "v3", expiry = 30.0)
|
||||
print("LIST:", await cache.list_keys())
|
||||
print("LIST:", await cache.list_keys(match = "k[1-2]"))
|
||||
print(await cache.get("k1"))
|
||||
await cache.delete("k1")
|
||||
print(await cache.get("k1"))
|
||||
print("LIST:", await cache.list_keys())
|
||||
|
||||
# print("\n\n---\n\n")
|
||||
# print("COUNTING:")
|
||||
# count = await cache.count("c1", expiry = 3.1)
|
||||
# for i in range(10):
|
||||
# time.sleep(1.0)
|
||||
# count = await cache.count("c1", expiry = 3.0, raise_exception = True)
|
||||
# ttl = await cache.ttl("c1")
|
||||
# print(count, await cache.get("c1"), ttl)
|
||||
# print("OUTSIDE LOOP!")
|
||||
# print(await cache.get("c1"))
|
||||
# time.sleep(3.1)
|
||||
# print(await cache.get("c1"))
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user