Partial Property Updates with Flask Caching

I recently updated my Dash application to version 2.9.2 to take advantage of the partial property updates and the Patch class (really like the update btw). Everything worked out fine. However, I want to do some further performance optimization because the app is still very slow at some points, so I started looking into cache and memoization.

The thing is, I added @cache.memoize… to one of my most expensive callbacks, in which I’m also updating a figure using Patch, and it’s throwing me “TypeError: ‘Patch’ object is not callable”, along with some other errors about serialization.

So my question is, am I doing something wrong? Can’t I use Patch and memoize in the same callback?

Here’s a simple example I created modifying one of the examples from the documentation on partial property updates. This fails for me.

import as px
import random
from dash import Dash, html, dcc, Input, Output, Patch
from flask_caching import Cache

app = Dash(__name__)
cache = Cache(app.server, config={
    'CACHE_TYPE': 'filesystem',
    'CACHE_DIR': 'cache'

df =
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species", title="Title Color")

app.layout = html.Div([
    html.Button("Update Graph Color", id="update-color-button-2"),
    dcc.Graph(figure=fig, id="my-fig"),

    Output("my-fig", "figure"),
    Input("update-color-button-2", "n_clicks")
def my_callback(n_clicks):
    # Defining a new random color
    red = random.randint(0, 255)
    green = random.randint(0, 255)
    blue = random.randint(0, 255)
    new_color = f"rgb({red}, {green}, {blue})"

    # Creating a Patch object
    patched_figure = Patch()
    patched_figure["layout"]["title"]["font"]["color"] = new_color
    return patched_figure

if __name__ == "__main__":

Thanks in advance for any assistance you can provide!