Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我想问一下问题 #1

Open
yuangu opened this issue May 2, 2020 · 5 comments
Open

我想问一下问题 #1

yuangu opened this issue May 2, 2020 · 5 comments

Comments

@yuangu
Copy link

yuangu commented May 2, 2020

数据库读取是异步的,redis也是异步的。假如有两个接口都先读数据库,处理完逻辑。再再写redis。 假如说,有两条接口同时请求,会不会造成数据不一致啊?

@caohao-go
Copy link
Owner

数据库读取是异步的,redis也是异步的。假如有两个接口都先读数据库,处理完逻辑。再再写redis。 假如说,有两条接口同时请求,会不会造成数据不一致啊?

这里采用的是 swoole 协程,实际上编程上来说是同步的,底层异步调度机制会帮我们维护好连接一致性

@yuangu
Copy link
Author

yuangu commented May 18, 2020

你还是没有懂我意思。 虽说编写代码是同步的,但是实际还是异步的。

@yuangu
Copy link
Author

yuangu commented May 18, 2020

如果有两个异步调用。在一个异步回调改了数据 ,然后在第二个异步后回调后存数据 。你会不会觉得这个过程会有问题?

@caohao-go
Copy link
Owner

如果有两个异步调用。在一个异步回调改了数据 ,然后在第二个异步后回调后存数据 。你会不会觉得这个过程会有问题?

没有问题的,底层会给你处理好,放心使用

@caohao-go
Copy link
Owner

如果有两个异步调用。在一个异步回调改了数据 ,然后在第二个异步后回调后存数据 。你会不会觉得这个过程会有问题?

协程上下文都会给你保存,哪个连接对应哪段代码!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants