Last active
October 2, 2025 13:10
-
-
Save up1/2189e81d802848f959ddaab3417d511b to your computer and use it in GitHub Desktop.
Revisions
-
up1 revised this gist
Oct 2, 2025 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ --- Install pg_cron CREATE EXTENSION pg_cron; --- Create cron job to call expire_rows() :: every hourly SELECT cron.schedule('0 * * * *', $$CALL expire_rows('1 hour');$$); -
up1 revised this gist
Oct 2, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ --- Create cron job to call expire_rows() :: every hourly SELECT cron.schedule('0 * * * *', $$CALL expire_rows('1 hour');$$); --- List all cron jobs -
up1 revised this gist
Oct 2, 2025 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ --- Create cron job to call expire_rows() :: every a hour SELECT cron.schedule('0 * * * *', $$CALL expire_rows('1 hour');$$); --- List all cron jobs SELECT * FROM cron.job; -
up1 revised this gist
Oct 2, 2025 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ CREATE OR REPLACE PROCEDURE expire_rows (retention_period INTERVAL) AS $$ BEGIN DELETE FROM cache_data WHERE created_at < NOW() - retention_period; COMMIT; END; $$ LANGUAGE plpgsql; -
up1 revised this gist
Oct 2, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,6 @@ CREATE UNLOGGED TABLE cache_data ( id serial PRIMARY KEY, key text UNIQUE NOT NULL, value jsonb, created_at timestamp); CREATE INDEX idx_cache_key ON cache_data (key); -
up1 created this gist
Oct 2, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ CREATE UNLOGGED TABLE cache_data ( id serial PRIMARY KEY, key text UNIQUE NOT NULL, value jsonb, inserted_at timestamp); CREATE INDEX idx_cache_key ON cache_data (key);