RefreshAssociationsService.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (C) 2024 Puter Technologies Inc.
  3. *
  4. * This file is part of Puter.
  5. *
  6. * Puter is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. const { Context } = require("../util/context");
  20. const BaseService = require("./BaseService");
  21. class RefreshAssociationsService extends BaseService {
  22. async ['__on_boot.consolidation'] () {
  23. const { refresh_associations_cache } = require('../helpers');
  24. await Context.allow_fallback(async () => {
  25. refresh_associations_cache();
  26. });
  27. setTimeout(() => {
  28. setInterval(async () => {
  29. await Context.allow_fallback(async () => {
  30. await refresh_associations_cache();
  31. })
  32. }, 30000);
  33. }, 15000)
  34. }
  35. }
  36. module.exports = { RefreshAssociationsService };