Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update invalid cache entry #24

Closed
wants to merge 1 commit into from

1 participant

@nulpunkt

When using Cassandra-PHP-Client-Library as the front-end lib and Cassandra Cluster Admin to create and modify schema's the cache will from time to time be invalid. This will update the cache in this case.

@nulpunkt nulpunkt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 23, 2012
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 3 deletions.
  1. +12 −3 Cassandra.php
View
15 Cassandra.php
@@ -1047,9 +1047,12 @@ public function getKeyspaceSchema($keyspace = null, $useCache = true) {
$schema = false;
$storeSchema = false;
+ if (function_exists('apc_fetch')) {
+ $storeSchema = true;
+ }
+
if ($useCache && function_exists('apc_fetch')) {
$schema = apc_fetch($cacheKey);
- $storeSchema = true;
}
if ($schema !== false) {
@@ -1880,7 +1883,13 @@ public function getSchema($useCache = true) {
$useCache
);
- if (!isset($keyspaceSchema['column-families'][$this->name])) {
+ // If we use cache, the cache may be wrong if column families has been changed by
+ // another lib
+ if ($useCache && !isset($keyspaceSchema['column-families'][$this->name])) {
+ return $this->getSchema(false);
+ }
+ // Else, we are wrong
+ else if (!isset($keyspaceSchema['column-families'][$this->name])) {
throw new CassandraColumnFamilyNotFoundException(
'Schema for column family "'.$this->name.'" not found'
);
@@ -3967,4 +3976,4 @@ class CassandraInvalidPatternException extends Exception {};
/**
* Thrown if requested method is not supported by Cassandra or this library
*/
-class CassandraUnsupportedException extends Exception {};
+class CassandraUnsupportedException extends Exception {};
Something went wrong with that request. Please try again.