Skip to content

Add composer cache class and table

Giorgenes Gelatti requested to merge 290288-composer-cache-pages into master

What does this MR do?

  • Adds the Composer cache class for handling composer cache pages
  • Creates the ComposerCachePage table to store composer cache pages

The cache class works by locking the metadata of a particular composer package (and related versions of the same package). After locking it, it generates the Version Index Json file and stores it. Old pages are marked for future deletion and the SHA of the new page is saved on the package metadata.

This saved SHA on the package metadata will allow for building the composer indexes faster and the pages will also allow it to be served directly from the cache.

Notice that this class is still not in use and will be called in a follow up MR.

Future work

  • Create worker to trigger using the cache whenever a Composer package is created/deleted
  • Worker for cleaning up unused cache pages
  • Task for building the cache pages of existing projects

Migrations

== 20210112202949 CreateComposerCacheFile: reverting ==========================
-- drop_table(:packages_composer_cache_files)
   -> 0.0251s
== 20210112202949 CreateComposerCacheFile: reverted (0.0252s) =================
== 20210112202949 CreateComposerCacheFile: migrating ==========================
-- create_table(:packages_composer_cache_files)
   -> 0.1009s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0004s
-- execute("ALTER TABLE packages_composer_cache_files\nADD CONSTRAINT check_84f5ba81f5\nCHECK ( char_length(file) <= 255 )\nNOT VALID;\n")
   -> 0.0012s
-- current_schema()
   -> 0.0003s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- execute("ALTER TABLE packages_composer_cache_files VALIDATE CONSTRAINT check_84f5ba81f5;")
   -> 0.0643s
-- execute("RESET ALL")
   -> 0.0003s
== 20210112202949 CreateComposerCacheFile: migrated (0.1886s) =================

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #290288 (closed)

Edited by Giorgenes Gelatti

Merge request reports