MetaCell / MetaCell/cloud-harness

Optimize and enable cache validation on Keycloak library

Open
#456 0 comments 0 reactions 1 assignee Claimed by @zsinnema View on GitHub
Dominant language
Python
Stars
19
Forks
5
Avg merge
3d 18h
Merged PRs (30d)
3

Description

Currently the Keycloak library of Cloud Harness uses the cachetool `cached` decorator to cache some frequently called functions.

For some applications that want to read the latest data from Keycloak this library should support cache invalidation or pass through options

With the cachetools library we could implement a "invalidate cache" function

see https://cachetools.readthedocs.io/en/latest/#cachetools.cached

```
from cachetools import cached, TTLCache
from threading import Lock

# since we are using one cache, make it big enough (512K should be enough)
cache = TTLCache(maxsize=512*1024, getsizeof=len)
lock = Lock()

@cached(cache, ttl=30, lock=lock)
def some_func_to_get_data_from_keycloak(params):
#
return some result

# invalidate / clear cache
def clear_cache():
with lock:
cache.clear()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.