refactor cache for attributes and indexes

This commit is contained in:
Everly Precia Suresh
2022-12-07 14:47:47 +00:00
parent ac6558b12e
commit ef77f0cd59
2 changed files with 3 additions and 8 deletions
-8
View File
@@ -125,9 +125,6 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded');
}
$dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId);
$dbForProject->deleteCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId());
$database
->setType(DATABASE_TYPE_CREATE_ATTRIBUTE)
->setDatabase($db)
@@ -1488,9 +1485,6 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key
$attribute = $dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'deleting'));
}
$dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId);
$dbForProject->deleteCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId());
$database
->setType(DATABASE_TYPE_DELETE_ATTRIBUTE)
->setCollection($collection)
@@ -1813,8 +1807,6 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
$index = $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'deleting'));
}
$dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId);
$database
->setType(DATABASE_TYPE_DELETE_INDEX)
->setDatabase($db)
+3
View File
@@ -279,6 +279,8 @@ Database::addFilter(
return null;
},
function (mixed $value, Document $document, Database $database) {
$database->deleteCachedDocument('database_' . $database->getInternalId(), $document['collectionId']);
$database->deleteCachedCollection('database_' . $database->getInternalId() . '_collection_' . $document['collectionInternalId']);
return $database
->find('attributes', [
Query::equal('collectionInternalId', [$document->getInternalId()]),
@@ -294,6 +296,7 @@ Database::addFilter(
return null;
},
function (mixed $value, Document $document, Database $database) {
$database->deleteCachedDocument('database_' . $document->getInternalId(), $document['collectionId']);
return $database
->find('indexes', [
Query::equal('collectionInternalId', [$document->getInternalId()]),