Gorm Source Code

Gorm Source Code 1. sql.DB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // driverConn wraps a driver.Conn with a mutex, to // be held during all calls into the Conn. (including any calls onto // interfaces returned via that Conn, such as calls on Tx, Stmt, // Result, Rows) type driverConn struct { db *DB createdAt time.Time sync.Mutex // guards following ci driver.Conn needReset bool // The connection session should be reset before use if true. closed bool finalClosed bool // ci.Close has been called openStmt map[*driverStmt]bool // guarded by db.mu inUse bool returnedAt time.Time // Time the connection was created or returned. onPut []func() // code (with db.mu held) run when conn is next returned dbmuClosed bool // same as closed, but guarded by db.mu, for removeClosedStmtLocked } sql.DB数据结构对数据库做了一层简单的抽象,但是需要明确的是:sql.DB不是一个连接,也不是映射到任何DataBase或者是Schema的概念。 ...

Dec 22, 2021 · 5 min · Chasing1020

Concurrency Programming

1. Implements volatile:声明后所有线程看到的改变量的值是一样的。写操作时,会添加Lock前缀的汇编。 保证了1. 保证缓存行的数据写回内存;2. 写回的操作会使其他缓存失效。 ...

Dec 05, 2021 · 7 min · Chasing1020

My CS Learning Route

As of the time I am writing this post, I have been studying computer science for a year and a half. I have started to organize and share my own computer science related study materials and routes. The courses in this schedule are not a substitute for college courses, but they can help you further your studies in computer science, or build an initial understanding of the field. In some ways, this route can be more of a substitute for college courses outside of class, as a required course to become an industry technician. ...

Nov 28, 2021 · 7 min · Chasing1020

Database Systems

Reference Book: Database System Concepts Seventh Edition 1. Relational Model Readings: Chapters 1-2, 6 Definition DataBase: Organized collection of inter-related data that models some aspect of the real-world. Databases are the core component of most computer applications. A database management system (DBMS) is software that allows applications to store and analyze information in a database. A general-purpose DBMS is designed to allow the definition, creation, querying, update, and administration of databases. Data Model: is a collection of concepts for describing the data in a database. Schema: is a description of a particular collection of data, using a given data model. ...

Nov 25, 2021 · 66 min · Chasing1020

Mathematic Fomulars

Mathematic Fomulars The mathematical typesetting is based on LaTeX, so if you need to search for the way to make a particular symbol, include latex in your search. But note: Not all LaTeX macros are available without using additional packages, and those packages likely will only work if you are creating a PDF. On the plus side, if you are working in PDF, you can use additional packages that give much better control and/or easier syntax. ...

Nov 20, 2021 · 3 min · Chasing1020