Also, is this a correct approach at caching?
My first thought was to override the fetch() method, but that method is final, and I'd rather not change something already embedded in Jooq itself
Keep in mind that I'm new to Jooq, so it's quite possible that I'm missing something obvious.
the ExecuteListener would activate your MockConnection if needed.
The VisitListener could be used to extract tables from a query
the ExecuteListener would activate your MockConnection if needed.How would this work? A MockConnection is registered when the DSLContext object is created, so how would you activate it through a listener?
The VisitListener could be used to extract tables from a queryI was thinking about this. But a VisitListener can't distinguish between reads and writes, and a ExecuteListener can, but it can't extract tables. How could I have them communicate?
-----------------------------------------
BEGIN CLAUSE LISTING:
INSERT
INSERT_INSERT_INTO
TABLE
TABLE_REFERENCE
END LISTING
QUERYPART LISTING:
insert into "org2"."accounts" ("name") values ('acct4'), ('acct5')
"org2"."accounts"
"org2"."accounts"
END QUERYPART LISTING
-----------------------------------------
-----------------------------------------
BEGIN CLAUSE LISTING:
INSERT
INSERT_INSERT_INTO
TABLE
TABLE_REFERENCE
END LISTING
QUERYPART LISTING:
insert into "org2"."accounts" ("name") values ('acct4'), ('acct5')
"org2"."accounts"
END QUERYPART LISTING
-----------------------------------------
-----------------------------------------
BEGIN CLAUSE LISTING:
INSERT
INSERT_INSERT_INTO
FIELD
END LISTING
QUERYPART LISTING:
insert into "org2"."accounts" ("name") values ('acct4'), ('acct5')
"name"
"name"
END QUERYPART LISTING
-----------------------------------------
-----------------------------------------
BEGIN CLAUSE LISTING:
INSERT
INSERT_INSERT_INTO
FIELD
END LISTING
QUERYPART LISTING:
insert into "org2"."accounts" ("name") values ('acct4'), ('acct5')
"name"
END QUERYPART LISTING
-----------------------------------------
The first listing is the result of VisitContext.clauses(), and the second is the result of VisitContext.queryParts(). This isn't all of the output; just the first few iterations. Can you give me a general overview of what's happening here? I'm really not understanding.
Thank you!
Also, this is from a visitEnd() repeated call.
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey,I do have invalidation set up (the cache uses Redis, so the ThreadLocal trick didn't end up being necessary), and this did end up working. Your method works like a charm for INSERT/UPDATE/DELETE/MERGE queries, making invalidation by table easy. Right now I'm trying to make it work similarly with arbitrarily nested SELECT queries, which I can already grab tables from using a recursive string-parsing method, but this would be cleaner. Otherwise, my current implementation, using a MockConnection/MockConnectionProvider/MockDataProvider, an ExecuteListener and VisitListener, and Jedis (java client for Redis), is fully functional with table-based invalidation and result storage and works on all types of queries. Thanks for all the help!
Do you have any suggestions on getting the tables of nested select queries (and from joins in those queries) through the VisitListener? Or should I just stick to my string parsing methods?
Never mind, I ended up finding a solution through the Visit Listener interface. The use case was that I wanted to create Redis lists of queries that involved the same table, so that I could easily invalidate a table when it's written to by getting a list of all the queries in the cache that involve that table, and delete them from Redis. This ended up being a lot easier than I thought it was, and it works as expected now!
Sure, I can make a blog post about this. I can't put it on Github, because this is a project for the company I'm interning at, so it isn't code I can share, but I can write a post about it, involving a simplified version of my work.
Hey,So I ended up making that blog post, you can see it here: http://aakashjapi.com/caching-with-jooq-and-redis/ . Tell me what you think! Also ignore that earlier reply I made to this (that was send for review), I accidentally used my other email.
--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/ayTAxqTXozw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.