我正在开发我的演示项目 - 它是一个简单的银行。
我有一个问题。
我需要向我的帐户添加一些虚拟货币。
但我需要“像原子操作一样”做到这一点,我需要在更新之前查询一些数据。
喜欢:
Query table A // select from table A
Query table B // select from table B
if (A + B > X)
Add money // insert into table C
Run Code Online (Sandbox Code Playgroud)
问题是,在查询 A 或 B 期间,另一个线程可以开始一些工作。
我应该使用mysql的哪种技术?
例子:快乐的例子
User see A = 1, B = 1 in dashboard
User will send request
SELECT A
SELECT B
INSERT A + B // result is 2
Run Code Online (Sandbox Code Playgroud)
可悲的例子
User see A = 1, B = 1 in dashboard …Run Code Online (Sandbox Code Playgroud) 我想阻止/public/configs我的 k8s 入口。
我当前的设置不起作用。
- host: example.com
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: service-myapp
port:
number: 80
- path: /public/configs
pathType: ImplementationSpecific
backend:
service:
name: service-myapp
port:
number: 88 // fake port
Run Code Online (Sandbox Code Playgroud)
有没有更好(简单)的方法?
我想在打字稿中实现深度选择。
我的示例代码是:
interface TestBook {
id: string;
name: string;
}
interface TestUser {
id: string;
email: string;
books: TestBook[];
}
Run Code Online (Sandbox Code Playgroud)
我和我想使用深度选择,例如:
const foo: DeepPick<TestUser, 'id' | 'books.name'> = {...
/*
{
id: ..
books: [{name: ...}]
}
*/
Run Code Online (Sandbox Code Playgroud)
问题:仅在标准打字稿中存在Pick,并且没有库实现此DeepPick。
我该怎么做?我应该使用哪种技术?
我试图在谷歌和SO上找到。