blastrain / rapidash Goto Github PK
View Code? Open in Web Editor NEWGo package for database record or other data caching
License: MIT License
Go package for database record or other data caching
License: MIT License
After trying to spin up the example project with postgres, I was met with the error:
panic: cannot warm up SecondLevelCache: cannot warm up SecondLevelCache. table is user_logins: failed show create table : failed to execute 'SHOW CREATE TABLE
user_logins': pq: syntax error at or near "CREATE"
Upon looking inside of first_lelvel_cache.go
it seems showCreateTable
unconditionally executes SHOW CREATE TABLE
which seems to be a mySQL specific syntax.
From what I can gather, it looks like you're attempting to dump the DDL of a given table. If so, something like:
SELECT *
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'user_logins'
ORDER BY ordinal_position;
Will give you:
table_catalog|table_schema|table_name |column_name |ordinal_position|column_default |is_nullable|data_type |character_maximum_length|character_octet_length|numeric_precision|numeric_precision_radix|numeric_scale|datetime_precision|interval_type|interval_precision|character_set_catalog|character_set_schema|character_set_name|collation_catalog|collation_schema|collation_name|domain_catalog|domain_schema|domain_name|udt_catalog|udt_schema|udt_name|scope_catalog|scope_schema|scope_name|maximum_cardinality|dtd_identifier|is_self_referencing|is_identity|identity_generation|identity_start|identity_increment|identity_maximum|identity_minimum|identity_cycle|is_generated|generation_expression|is_updatable|
-------------|------------|-----------|---------------|----------------|---------------------------------------|-----------|----------------------|------------------------|----------------------|-----------------|-----------------------|-------------|------------------|-------------|------------------|---------------------|--------------------|------------------|-----------------|----------------|--------------|--------------|-------------|-----------|-----------|----------|--------|-------------|------------|----------|-------------------|--------------|-------------------|-----------|-------------------|--------------|------------------|----------------|----------------|--------------|------------|---------------------|------------|
postgres |public |user_logins|id | 1|nextval('user_logins_id_seq'::regclass)|NO |bigint | | | 64| 2| 0| | | | | | | | | | | | |postgres |pg_catalog|int8 | | | | |1 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|user_id | 2| |NO |bigint | | | 64| 2| 0| | | | | | | | | | | | |postgres |pg_catalog|int8 | | | | |2 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|user_session_id| 3| |NO |bigint | | | 64| 2| 0| | | | | | | | | | | | |postgres |pg_catalog|int8 | | | | |3 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|login_param_id | 4| |NO |bigint | | | 64| 2| 0| | | | | | | | | | | | |postgres |pg_catalog|int8 | | | | |4 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|name | 5| |NO |character varying | 255| 1020| | | | | | | | | | | | | | | |postgres |pg_catalog|varchar | | | | |5 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|created_at | 6| |NO |time without time zone| | | | | | 6| | | | | | | | | | | |postgres |pg_catalog|time | | | | |6 |NO |NO | | | | | |NO |NEVER | |YES |
postgres |public |user_logins|updated_at | 7| |NO |time without time zone| | | | | | 6| | | | | | | | | | | |postgres |pg_catalog|time | | | | |7 |NO |NO | | | | | |NO |NEVER | |YES |
However I'm concerned there are more places that mySQL specific SQL is hiding throughout the codebase.
Are there any ongoing efforts to allow more generic queries to be executed to support more databases?
Current CRUD interfaces using QueryBuilder are persistent to backend RDB and I understand that it is necessary to keep atomicity between cache and DB record.
However, sometimes I wanted to delete only second level cache with condition.
If it is OK to add new interface or option, please let me work for this.
Supporting Update and Create clause breaks atomicity between cache and DB records.
I thought it is against to this module's policy so I focused to Delete operation in this topic.
builder := rapidash.NewQueryBuilder("methods").
Eq("code", code)
tx.FindByQueryBuilder(builder, &method)
no rows found from db, but i am 100 percent sure there's record in database.
debug log:
{"level":"info","id":"bs5jqb3k3a68d31cfl8g","command":"get","type":"db","key":"SELECT `code`,`name`,`description`,`currency`,`type`,`amount_min`,`amount_max`,`created_at`,`updated_at`,`deleted_at` FROM `methods` WHERE `code` = ?","args":["\"CNYCC\""],"value":"[]","time":1594572076,"message":"<----get------[stash]-----[db]"}
{"level":"info","id":"bs5jqb3k3a68d31cfl8g","command":"set","type":"stash","key":"r/slc/methods/code#\"\\\"CNYCC\\\"\"","value":"nil","time":1594572076,"message":"----set------>[stash] [server]"}
{"level":"info","id":"bs5jqb3k3a68d31cfl8g","command":"add","type":"server","key":"r/slc/methods/code#\"\\\"CNYCC\\\"\"/lock","value":"{ \"id\": bs5jqb3k3a68d31cfl8g, \"key\": r/slc/methods/code#\"\\\"CNYCC\\\"\", \"time\": 2020-07-13 00:41:16.140798 +0800 CST m=+6.040811516 }","time":1594572076,"message":"----add-------[stash]---->[server]"}
{"level":"info","id":"bs5jqb3k3a68d31cfl8g","command":"set","type":"server","key":"r/slc/methods/code#\"\\\"CNYCC\\\"\"","value":"nil","time":1594572076,"message":"----set-------[stash]---->[server]"}
{"level":"info","id":"bs5jqb3k3a68d31cfl8g","command":"delete","type":"server","key":"r/slc/methods/code#\"\\\"CNYCC\\\"\"/lock","time":1594572076,"message":"---delete-----[stash]---->[server]"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.