Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling cache #4805

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class KeycloakAdminService:
def get_token(self):
_accesstoken=None
try:
#cache_client = redis.from_url(self.cache_redis_url,decode_responses=True)
_accesstoken = None #cache_client.get("foi:kcsrcacnttoken")
cache_client = redis.from_url(self.cache_redis_url,decode_responses=True)
_accesstoken = cache_client.get("foi:kcsrcacnttoken")
if _accesstoken is None:
url = '{0}/auth/realms/{1}/protocol/openid-connect/token'.format(self.keycloakhost,self.keycloakrealm)
params = {
Expand All @@ -38,11 +38,11 @@ def get_token(self):
}
x = requests.post(url, params, verify=True).content.decode('utf-8')
_accesstoken = str(ast.literal_eval(x)['access_token'])
#cache_client.set("foi:kcsrcacnttoken",_accesstoken,ex=int(self.kctokenexpiry))
cache_client.set("foi:kcsrcacnttoken",_accesstoken,ex=int(self.kctokenexpiry))
except BusinessException as exception:
print("Error happened while accessing token on KeycloakAdminService {0}".format(exception.message))
# finally:
# cache_client = None
finally:
cache_client = None
return _accesstoken


Expand Down
Loading