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

Add new method:apcu_exists_any #389

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fuzhufang
Copy link

apcu_exists_any: In the array parameters passed in, look up in order, as soon as you find one, exit immediately, return true. Application scenario: You only need to know if one of all the keys exists, you don't need to know if all the keys exist, and you don't need to know who the keys are.

… as soon as you find one, exit immediately, return true. Application scenario: You only need to know if one of all the keys exists, you don't need to know if all the keys exist, and you don't need to know who the keys are.
@nikic
Copy link
Collaborator

nikic commented Oct 30, 2019

Do you have an example where this would be used? I'm wondering if it wouldn't be better to at least return which of the keys is the one that exists.

@fuzhufang
Copy link
Author

Do you have an example where this would be used? I'm wondering if it wouldn't be better to at least return which of the keys is the one that exists.

For example: I have an IP whitelist and a device whitelist and even more conditions. Every time the user accesses the service, we need to check whether it is an IP whitelist or whether it is a device whitelist or other conditions, but I Just need to know if one is established. I think using apcu_exists can also satisfy this requirement, but it would be more efficient if you use apcu_exists_any. Or you have a better solution

I agree that it is better to return which key is the key that exists, thank you for your comment.

@stof
Copy link

stof commented Sep 12, 2023

if the implementation only loops synchronously over the keys to check if the key exists, is there any benefit about doing that in the extension vs doing it in userland ?

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

Successfully merging this pull request may close these issues.

3 participants