I have consistently receiving the warning:will not produce a cache key because the ``cache_ok`` flag is not set to True. Set this flag to True if this type object's state is safe to use in a cache key, or False to disable this warning.After reading the documentation, I learned that the "cache_ok" class-level attribute can be set to either True or False. But the documentation is very abstract on when to use it? What is cache key? Is it for loading and caching a set of objects from the database? Or caching the query itself?
If my TypeDecorator class doesn't even have a __init__method, just "process_bind_param" and "process_result_value" two methods, do I even need to bother with this "cache_ok" setting at all?
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.---You received this message because you are subscribed to the Google Groups "sqlalchemy" group.To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/abe578f0-fd11-468f-857d-dee6fd77ebc5n%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/zCPZKTxM6b0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/f3640072-8d16-4f59-bc67-f468c78878cb%40www.fastmail.com.
class TZDateTime(TypeDecorator): impl = DateTime cache_ok = True def process_bind_param(self, value, dialect): if value is not None: if not value.tzinfo: raise TypeError("tzinfo is required") value = value.astimezone(datetime.timezone.utc).replace( tzinfo=None ) return value def process_result_value(self, value, dialect): if value is not None: value = value.replace(tzinfo=datetime.timezone.utc) return value
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOQAhNf94F7XHBZ28LEKe5TmC7Q4vKRbiNSZX48waASnGgYJPQ%40mail.gmail.com.