gustavehub / data /caching.py
datacipen's picture
Upload caching.py
304e30e verified
raw
history blame contribute delete
734 Bytes
import pandas as pd
from flask_caching import Cache
# Dummy function to simulate loading data from an Excel file
def load_excel_data(file_path):
# In a real application, you would use pd.read_excel(file_path)
# For now, we'll return a dummy dataframe
print(f"Loading data from {file_path}...")
return pd.DataFrame({
'Column1': [1, 2, 3, 4],
'Column2': [10, 20, 30, 40],
'Column3': ['A', 'B', 'C', 'D']
})
def setup_caching(app):
cache = Cache(app.server, config={
'CACHE_TYPE': 'filesystem',
'CACHE_DIR': 'cache-directory'
})
@cache.memoize()
def get_data(file_path):
return load_excel_data(file_path)
return get_data