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

falling back to internal cache #54

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,27 +881,22 @@ public function add( $key, $value, $group = 'default', $expiration = 0, $server_
$derived_key = $this->buildKey( $key, $group );
$expiration = $this->sanitize_expiration( $expiration );

// If group is a non-Memcached group, save to runtime cache, not Memcached
if ( in_array( $group, $this->no_mc_groups ) ) {

// Add does not set the value if the key exists; mimic that here
if ( isset( $this->cache[$derived_key] ) )
return false;

$this->add_to_internal_cache( $derived_key, $value );

return true;
// Skip saving to Memcached if group is a non-Memcached group
if ( ! in_array( $group, $this->no_mc_groups ) ) {
// Save to Memcached
if ( $byKey )
$result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
else
$result = $this->m->add( $derived_key, $value, $expiration );
}

// Save to Memcached
if ( $byKey )
$result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
else
$result = $this->m->add( $derived_key, $value, $expiration );

// Store in runtime cache if add was successful
if ( Memcached::RES_SUCCESS === $this->getResultCode() )
// Add does not set the value if the key exists; mimic that here
if ( isset( $this->cache[$derived_key] ) )
$result=false;
else{
$this->add_to_internal_cache( $derived_key, $value );
$result=true;
}

return $result;
}
Expand Down