* feat: add 60-second cache for workspace key retrieval This implements a cache with 60-second staleness for the get_workspace_key function to reduce database queries for workspace encryption keys. The cache follows the same pattern as the existing CUSTOM_ENVS_CACHE but with a shorter expiration time. Requested by @rubenfiszel Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * Extend cache staleness from 60 to 300 seconds * feat: add cache invalidation notifications for workspace keys Add PostgreSQL LISTEN/NOTIFY mechanism to invalidate workspace key cache across all servers and workers when workspace keys change. - Add database migration with trigger function for workspace_key changes - Add notification handler in main.rs to remove from WORKSPACE_KEY_CACHE - Follow same pattern as existing workspace environment cache invalidation - Ensures distributed cache consistency for workspace encryption keys Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com> * finish --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com>
19 lines
564 B
PL/PgSQL
19 lines
564 B
PL/PgSQL
-- Add workspace key cache invalidation trigger
|
|
|
|
CREATE OR REPLACE FUNCTION notify_workspace_key_change()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
IF TG_OP = 'DELETE' THEN
|
|
PERFORM pg_notify('notify_workspace_key_change', OLD.workspace_id);
|
|
RETURN OLD;
|
|
ELSE
|
|
PERFORM pg_notify('notify_workspace_key_change', NEW.workspace_id);
|
|
RETURN NEW;
|
|
END IF;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
CREATE TRIGGER workspace_key_change_trigger
|
|
AFTER INSERT OR UPDATE OF key OR DELETE ON workspace_key
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION notify_workspace_key_change(); |