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

Update Redis.zep #16251

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

Update Redis.zep #16251

wants to merge 3 commits into from

Conversation

zikezhang
Copy link
Contributor

@zikezhang zikezhang commented Dec 26, 2022

add ttl() and pttl() to that developer can get Redis TTL.

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR

Small description of change:
add ttl(), pttl() for Redis.
Thanks

add ttl() and pttl() to that developer can get Redis TTL.
@Jeckerson
Copy link
Member

@zikezhang Could you please add some basic tests for theses methods?

zikezhang and others added 2 commits December 27, 2022 08:20
add function to return the time to live left for a given key in seconds (ttl), or milliseconds (pttl).
@zikezhang
Copy link
Contributor Author

@zikezhang Could you please add some basic tests for theses methods?

Hi @Jeckerson, yes, I will. I am sorry for the inconvenience. So, one of my project, I need to implement a throttle middleware by updating the value in Redis without changing the TTL. I have to code it like this:

 $ttl  = $hits ? $cache->getAdapter()->getAdapter()->ttl($key) 
               :  $minutes * 60;

As you can see. I have to call getAdapter() twice to invoke it.
We might add a similar function on each Adapter and then we can get the TTL by $cache->ttl($key)

@niden
Copy link
Member

niden commented Dec 27, 2022

@zikezhang Could you please add some basic tests for theses methods?

Hi @Jeckerson, yes, I will. I am sorry for the inconvenience. So, one of my project, I need to implement a throttle middleware by updating the value in Redis without changing the TTL. I have to code it like this:

 $ttl  = $hits ? $cache->getAdapter()->getAdapter()->ttl($key) 
               :  $minutes * 60;

As you can see. I have to call getAdapter() twice to invoke it. We might add a similar function on each Adapter and then we can get the TTL by $cache->ttl($key)

Adding this to the Cache layer will alter the interface and we will need to add all these methods to the adapters and relevant interface also

We need to explore what the other adapters offer in terms of TTL so as to promote it to the adapter. Also the Cache adapters rely on the Storage namespace so all changes have to happen there first.

@rudiservo
Copy link
Contributor

apcu has this on https://www.php.net/manual/en/function.apcu-key-info.php

Memcached has something called MetaCommands, unfortunately php-memcached is heavily reliant on libmemcached that is a bit behind.
Already submitted an issue on lauchpad on the libmemcached project.

There is a project https://github.com/awesomized/libmemcached that is trying to implement the meta protocol for the past 3 years.

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.

4 participants