Dogpile session caching

22 views
Skip to first unread message

Joe Black

unread,
Aug 2, 2023, 2:05:25 PM8/2/23
to sqlalchemy
Hello,

First of all, excellent project!  It's such a powerful tool when you really master the internals, and after several years I think I'm nearing that point.  

My question today is related to the dogpile caching examples.  I migrated to 2.x awhile back but the given examples in the documentation for 2.x show the Session.query interface being used.  I understand this has been deprecated starting with 2.x, so naturally I've migrated existing code using Session.query.  This seems to break the example code for dogpile caching.

I was hoping to get some advice on how to implement the caching using the new unified sa.select and Session.execute/Session.scalars interface, or even whether dogpile cache supports this interface yet?

Thanks in advance,

Joe

Mike Bayer

unread,
Aug 2, 2023, 11:44:05 PM8/2/23
to noreply-spamdigest via sqlalchemy
I've just updated them to use new style queries.   There were no issues and all the examples work by switching `Session.query(Thing)` for `Session.scalars(select(Thing))`.     The examples will be on the site within an hour but you can see the changes made in https://github.com/sqlalchemy/sqlalchemy/commit/ab413c3c7b655d408d925dfba47f54c207b9668b .
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To 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.

Mike Bayer

unread,
Aug 2, 2023, 11:52:46 PM8/2/23
to noreply-spamdigest via sqlalchemy
I will note, in case you didn't see it, that in SQLAlchemy 1.4 (as well as in 2.0) the caching mechanics themselves have changed compared to what they were in SQLAlchemy 1.3.  This change was first made in the 1.4 series to use the new do_orm_execute() event model, whereas previously in 1.3 there was a Query subclass called CachingQuery or something like that.   for 1.4 and above you would need to be using the do_orm_execute() code.
Reply all
Reply to author
Forward
0 new messages