Added jitter function to the cache #618

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
@Jeraimee

No description provided.

@AD7six

This comment has been minimized.

Show comment
Hide comment
@AD7six

AD7six Apr 20, 2012

Member

"No description given." click edit please

Member

AD7six commented Apr 20, 2012

"No description given." click edit please

@@ -239,6 +239,11 @@ public static function set($settings = array(), $value = null, $config = 'defaul
if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
$settings['duration'] = strtotime($settings['duration']) - time();
}
+ if (isset($settings['duration']) && isset($settings['jitter'])) {
+ $jitter = rand(0, $settings['jitter']);
+ $plus_or_minus = (bool) rand(0, 1);

This comment has been minimized.

@markstory

markstory Apr 20, 2012

Member

Should be $plusOrMinus

@markstory

markstory Apr 20, 2012

Member

Should be $plusOrMinus

+ * In systems with large caches this can lessen the thundering hurd effect.
+ * In development mode, use no jitter
+ */
+$jitter = 300;

This comment has been minimized.

@markstory

markstory Apr 21, 2012

Member

5 minutes seems like a long time for a default jitter value. Wouldn't 1 minute work just as well.

@markstory

markstory Apr 21, 2012

Member

5 minutes seems like a long time for a default jitter value. Wouldn't 1 minute work just as well.

+ if (isset($settings['duration']) && isset($settings['jitter'])) {
+ $jitter = rand(0, $settings['jitter']);
+ $plus_or_minus = (bool) rand(0, 1);
+ $settings['duration'] = ($plus_or_minus) ? ($settings['duration'] + $jitter) : ($settings['duration'] - $jitter);

This comment has been minimized.

@markstory

markstory Apr 21, 2012

Member

You don't safeguard against the duration becoming 0. If for example the duration and jitter are the same, or the jitter is greater than the duration, you could end up with 0 or fewer seconds as the duration.

@markstory

markstory Apr 21, 2012

Member

You don't safeguard against the duration becoming 0. If for example the duration and jitter are the same, or the jitter is greater than the duration, you could end up with 0 or fewer seconds as the duration.

@@ -250,6 +250,16 @@
$duration = '+10 seconds';
}
+/**
+ * The number of seconds (if any) to add or subtract from the cache duration.
+ * In systems with large caches this can lessen the thundering hurd effect.

This comment has been minimized.

@ADmad

ADmad May 20, 2012

Member

s/hurd/herd

@ADmad

ADmad May 20, 2012

Member

s/hurd/herd

@ghost ghost assigned markstory May 21, 2012

@lorenzo

This comment has been minimized.

Show comment
Hide comment
@lorenzo

lorenzo Dec 22, 2012

Member

There was no follow up on this PR after 8 months. APC already implement this type of feature so I don't think we should duplicate it anyway.

Member

lorenzo commented Dec 22, 2012

There was no follow up on this PR after 8 months. APC already implement this type of feature so I don't think we should duplicate it anyway.

@lorenzo lorenzo closed this Dec 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment