小编tet*_*241的帖子

mysql中如何实现原子事务?

我正在开发我的演示项目 - 它是一个简单的银行。

我有一个问题。

我需要向我的帐户添加一些虚拟货币。

但我需要“像原子操作一样”做到这一点,我需要在更新之前查询一些数据。

喜欢:

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)

mysql atomic

6
推荐指数
1
解决办法
1862
查看次数

如何拒绝 k8S 入口中的路径

我想阻止/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)

有没有更好(简单)的方法?

kubernetes kubernetes-ingress

6
推荐指数
1
解决办法
2225
查看次数

如何在打字稿中实现深度选择

我想在打字稿中实现深度选择。

我的示例代码是:

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上找到。

javascript types object typescript

4
推荐指数
1
解决办法
1004
查看次数