Skip to main content
added 21 characters in body
Source Link
taylor
  • 1.1k
  • 1
  • 9
  • 19

Is it possible to find the seconds left / TTL when retrieving cache (when set to Redis) via Pluginplugins? I'm using short-lived cache (~600 seconds) to put users on "cooldown" to limit how often they can create new forum topics, by creating a user-specific cache whenever they create a topic. Then I can check and see if this cache exists when they create a new topic.

When getting the cache like:

$cache = craft()->cache->get( $cacheKey );

If it returns true (exists,) I'd like to be able to tell the user how long they need to wait until they can post again (like Reddit.)

I've tried methods like

$cache->ttl; // doesn't work; not an object
$cache['ttl']; // doesn't work, no 'ttl' key

Maybe I am missing something in the Cache Service Doc? Or is this meta information simply not available?

Any information would be awesome. Cheers!

Is it possible to find the seconds left / TTL when retrieving cache via Plugin? I'm using short-lived cache (~600 seconds) to put users on "cooldown" to limit how often they can create new forum topics, by creating a user-specific cache whenever they create a topic. Then I can check and see if this cache exists when they create a new topic.

When getting the cache like:

$cache = craft()->cache->get( $cacheKey );

If it returns true (exists,) I'd like to be able to tell the user how long they need to wait until they can post again (like Reddit.)

I've tried methods like

$cache->ttl; // doesn't work; not an object
$cache['ttl']; // doesn't work, no 'ttl' key

Maybe I am missing something in the Cache Service Doc? Or is this meta information simply not available?

Any information would be awesome. Cheers!

Is it possible to find the seconds left / TTL when retrieving cache (when set to Redis) via plugins? I'm using short-lived cache (~600 seconds) to put users on "cooldown" to limit how often they can create new forum topics, by creating a user-specific cache whenever they create a topic. Then I can check and see if this cache exists when they create a new topic.

When getting the cache like:

$cache = craft()->cache->get( $cacheKey );

If it returns true (exists,) I'd like to be able to tell the user how long they need to wait until they can post again (like Reddit.)

I've tried methods like

$cache->ttl; // doesn't work; not an object
$cache['ttl']; // doesn't work, no 'ttl' key

Maybe I am missing something in the Cache Service Doc? Or is this meta information simply not available?

Any information would be awesome. Cheers!

Source Link
taylor
  • 1.1k
  • 1
  • 9
  • 19

Craft Redis Cache - Get Time Left?

Is it possible to find the seconds left / TTL when retrieving cache via Plugin? I'm using short-lived cache (~600 seconds) to put users on "cooldown" to limit how often they can create new forum topics, by creating a user-specific cache whenever they create a topic. Then I can check and see if this cache exists when they create a new topic.

When getting the cache like:

$cache = craft()->cache->get( $cacheKey );

If it returns true (exists,) I'd like to be able to tell the user how long they need to wait until they can post again (like Reddit.)

I've tried methods like

$cache->ttl; // doesn't work; not an object
$cache['ttl']; // doesn't work, no 'ttl' key

Maybe I am missing something in the Cache Service Doc? Or is this meta information simply not available?

Any information would be awesome. Cheers!