Skip to content

Commit

Permalink
fix: clear permission cache on configuration save
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Nov 6, 2024
1 parent ccd3631 commit 044acd7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/WorkspaceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public static function saveWorkspaces(Configuration $config, $workspaces)
}
}
}
Cache::clearTags(self::getCacheTags($config));
}

/**
Expand Down Expand Up @@ -210,6 +211,8 @@ public static function deleteConfiguration(Configuration $config)
$db->delete(Dao::TABLE_NAME_DOCUMENT, ['configuration' => $config->getName()]);
$db->delete(Dao::TABLE_NAME_ASSET, ['configuration' => $config->getName()]);
$db->delete(Dao::TABLE_NAME_DATAOBJECT, ['configuration' => $config->getName()]);

Cache::clearTags(self::getCacheTags($config));
}

/**
Expand Down Expand Up @@ -302,7 +305,7 @@ public static function isAllowed($element, Configuration $configuration, string

private static function fetchLookupTable(string $elementType, Configuration $configuration): array
{
$cacheKey = 'datahub_permissions_' . $configuration->getName() . '_' . $elementType;
$cacheKey = 'datahub_workspace_permissions_' . $configuration->getName() . '_' . $elementType;
if (RuntimeCache::isRegistered($cacheKey)) {
return RuntimeCache::load($cacheKey);
}
Expand All @@ -324,8 +327,13 @@ private static function fetchLookupTable(string $elementType, Configuration $con
}

RuntimeCache::save($lookupTable, $cacheKey);
Cache::save($lookupTable, $cacheKey);
Cache::save($lookupTable, $cacheKey, self::getCacheTags($configuration));

return $lookupTable;
}

private static function getCacheTags(Configuration $configuration): array
{
return ['datahub_workspace_permissions_'. $configuration->getName()];
}
}

0 comments on commit 044acd7

Please sign in to comment.