clean cache data
This commit is contained in:
@@ -27,6 +27,10 @@ class BaseService:
|
|||||||
SEND_EMAIL_PASS = Config.SEND_EMAIL_PASS
|
SEND_EMAIL_PASS = Config.SEND_EMAIL_PASS
|
||||||
THIS_SITE_URL = Config.THIS_SITE_URL
|
THIS_SITE_URL = Config.THIS_SITE_URL
|
||||||
|
|
||||||
|
CACHE_SERVER = Config.CACHE_SERVER
|
||||||
|
CACHE_PORT = Config.CACHE_PORT
|
||||||
|
CACHE_PASSWORD = Config.CACHE_PASSWORD
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addStripeCustomer(customerData):
|
def addStripeCustomer(customerData):
|
||||||
customer_data = {
|
customer_data = {
|
||||||
@@ -391,39 +395,21 @@ class BaseService:
|
|||||||
def write_cache_data(cacheSection, cacheId, cacheData):
|
def write_cache_data(cacheSection, cacheId, cacheData):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cacheKey = cacheSection + ':' + cacheId
|
cacheKey = cacheSection + '-' + cacheId
|
||||||
logger.info(f"write_cache_data () key {cacheKey}", exc_info=True)
|
logger.info(f"write_cache_data () key {cacheKey}", exc_info=True)
|
||||||
# Define connection parameters and connect
|
# Define connection parameters and connect
|
||||||
r = redis.Redis(host='10.10.33.35', port=6378,
|
r = redis.Redis(host=BaseService.CACHE_SERVER, port=BaseService.CACHE_PORT,
|
||||||
password='7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5',
|
password=BaseService.CACHE_PASSWORD,
|
||||||
decode_responses=True)
|
decode_responses=True)
|
||||||
|
|
||||||
# Set a key 'foo' with value 'bar'
|
# Set a key 'foo' with value 'bar'
|
||||||
json_string = json.dumps(cacheData, indent=4)
|
json_string = json.dumps(cacheData, indent=4)
|
||||||
r.set(cacheKey, json_string)
|
r.set(cacheKey, json_string, ex=120)
|
||||||
|
|
||||||
# Verify by getting the value
|
# Verify by getting the value
|
||||||
value = r.get(cacheKey)
|
value = r.get(cacheKey)
|
||||||
print(f"Value of {cacheKey}: {value}") # Output: Value of 'foo': bar
|
print(f"Value of {cacheKey}: {value}") # Output: Value of 'foo': bar
|
||||||
|
|
||||||
# Store a user session as a hash
|
|
||||||
# user_data = {
|
|
||||||
# 'name': 'John',
|
|
||||||
# 'surname': 'Smith',
|
|
||||||
# 'company': 'Redis',
|
|
||||||
# 'age': 29
|
|
||||||
# }
|
|
||||||
# json_string = json.dumps(cacheData, indent=4)
|
|
||||||
#
|
|
||||||
# r.set(cacheSection + ':user-session:123', json_string)
|
|
||||||
|
|
||||||
# r.hset(cacheSection +':user-session:123', mapping=json_string)
|
|
||||||
|
|
||||||
# Retrieve all fields of the hash
|
|
||||||
# session_details = r.hgetall('user-session:123')
|
|
||||||
# print(f"Session details: {session_details}")
|
|
||||||
# Output: Session details: {'name': 'John', 'surname': 'Smith', 'company': 'Redis', 'age': '29'}
|
|
||||||
|
|
||||||
response_data = {
|
response_data = {
|
||||||
"session_details": value,
|
"session_details": value,
|
||||||
# "product_id": product_id,
|
# "product_id": product_id,
|
||||||
|
|||||||
+9
-2
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Base configuration for Flask app"""
|
"""Base configuration for Flask app"""
|
||||||
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "")
|
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "")
|
||||||
@@ -44,13 +45,13 @@ class Config:
|
|||||||
# KAFKA_BROKER = 'dev-events.simbrellang.net:9085'
|
# KAFKA_BROKER = 'dev-events.simbrellang.net:9085'
|
||||||
KAFKA_BROKER = os.getenv("KAFKA_BROKER", "10.10.10.120:9092")
|
KAFKA_BROKER = os.getenv("KAFKA_BROKER", "10.10.10.120:9092")
|
||||||
|
|
||||||
STRIPE_SUCCESS_URL = os.environ.get("STRIPE_SUCCESS_URL","https://qa-panel.mermsemr.com/subscription-success?session_id={CHECKOUT_SESSION_ID}")
|
STRIPE_SUCCESS_URL = os.environ.get("STRIPE_SUCCESS_URL",
|
||||||
|
"https://qa-panel.mermsemr.com/subscription-success?session_id={CHECKOUT_SESSION_ID}")
|
||||||
STRIPE_CANCEL_URL = os.environ.get("STRIPE_CANCEL_URL", "https://qa-panel.mermsemr.com/subscriptio")
|
STRIPE_CANCEL_URL = os.environ.get("STRIPE_CANCEL_URL", "https://qa-panel.mermsemr.com/subscriptio")
|
||||||
|
|
||||||
VALID_APP_ID = os.getenv("SIMBRELLA_APP_ID", "app1")
|
VALID_APP_ID = os.getenv("SIMBRELLA_APP_ID", "app1")
|
||||||
VALID_API_KEY = os.getenv("SIMBRELLA_API_KEY", "test-api-key-12345")
|
VALID_API_KEY = os.getenv("SIMBRELLA_API_KEY", "test-api-key-12345")
|
||||||
|
|
||||||
|
|
||||||
# SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337")
|
# SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337")
|
||||||
# SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS","api/rac-check")
|
# SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS","api/rac-check")
|
||||||
# SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS", "RACCheck")
|
# SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS", "RACCheck")
|
||||||
@@ -101,4 +102,10 @@ class Config:
|
|||||||
UPLOAD_FOLDER = os.environ.get("UPLOAD_FOLDER", "/app/uploads/DEV")
|
UPLOAD_FOLDER = os.environ.get("UPLOAD_FOLDER", "/app/uploads/DEV")
|
||||||
MEDIA_SERVER = os.environ.get("MEDIA_SERVER", "https://media.mermsemr.com")
|
MEDIA_SERVER = os.environ.get("MEDIA_SERVER", "https://media.mermsemr.com")
|
||||||
|
|
||||||
|
CACHE_SERVER = os.environ.get("CACHE_SERVER", "10.10.33.35")
|
||||||
|
CACHE_PORT = os.environ.get("CACHE_PORT", 6378)
|
||||||
|
CACHE_PASSWORD = os.environ.get("CACHE_PASSWORD",
|
||||||
|
"7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5")
|
||||||
|
|
||||||
|
|
||||||
settings = Config()
|
settings = Config()
|
||||||
|
|||||||
Reference in New Issue
Block a user