Commit Graph

25 Commits

Author SHA1 Message Date
Heinrich Lee Yu 0c30052427
Use strong memoize utility 2018-11-26 17:41:41 +08:00
Heinrich Lee Yu 3b49a7948c
Prevent loading from cache if commit is nil 2018-11-26 17:41:40 +08:00
Heinrich Lee Yu 0047429a97
Cache project HEAD to prevent unnecessary Gitaly calls 2018-11-26 17:41:39 +08:00
Gabriel Mazetto cb541aef89 Change project pipeline status cache key to follow project convention
Old cache key was: `projects/#{id}/pipeline_status/#{sha}`
New one is: `project:#{id}:pipeline_status:#{sha}`

This allows to delete any project related key just by scanning for:
`project:#{id}`.
2018-11-16 16:22:53 +01:00
Matija Čupić 0079fa19ce
Remove cache_sha parameter 2018-10-26 14:53:04 +02:00
Matija Čupić dd2e91cc78
Cache pipeline status only for specific sha 2018-10-25 19:57:08 +02:00
gfyoung e166e5747c Enable some frozen string in lib/gitlab
Enable frozen string for the following files:

* lib/gitlab/auth/**/*.rb
* lib/gitlab/badge/**/*.rb
* lib/gitlab/bare_repository_import/**/*.rb
* lib/gitlab/bitbucket_import/**/*.rb
* lib/gitlab/bitbucket_server_import/**/*.rb
* lib/gitlab/cache/**/*.rb
* lib/gitlab/checks/**/*.rb

Partially addresses #47424.
2018-10-13 02:31:31 -07:00
Michael Kozono a54a5d9f39 Use `Gitlab::SafeRequestStore` in more places
Even if it doesn’t save lines of code, since people will tend to use
code they’ve seen. And `SafeRequestStore` is safer since you
don’t have to remember to check `RequestStore.active?`.
2018-09-24 12:11:27 -07:00
Lin Jen-Shin d5c7fe29c8 Add docs for RequestCache, moved from comments 2018-06-22 18:18:42 +08:00
Lin Jen-Shin 4b30aec0aa Allow `rake cache:clear` clearing pipeline status cache
* Use the correct key prefix
* Clear old cache keys

TODO:

At some point we could remove clearing old cache keys.
2018-04-10 20:57:00 +08:00
Lin Jen-Shin 9ac0c76b78 Use StrongMemoize and enable/disable cops properly 2017-11-18 01:01:53 +08:00
Lin Jen-Shin 9ae92b8caa Add cop to make sure we don't use ivar in a module 2017-09-18 21:23:45 +08:00
Robert Speicher 260c8da060 Whitelist or fix additional `Gitlab/PublicSend` cop violations
An upcoming update to rubocop-gitlab-security added additional
violations.
2017-08-14 12:14:11 -04:00
Lin Jen-Shin 3922b80329 Rename the methods to make it fit with current name 2017-07-18 18:04:20 +08:00
Lin Jen-Shin ffc5b29bd0 Follow feedback on the merge request 2017-07-18 17:48:48 +08:00
Lin Jen-Shin 76c9f071db Update the comments for the new functionality 2017-07-18 01:30:58 +08:00
Lin Jen-Shin aada5273fa Use RequestStoreWrap for Commit#author
We also try to use instance variable to cache the result if
RequestStore is not available, so we could keep the same logic,
using the same cache key. Also introduce a way to specify method
specific cache key
2017-07-18 01:18:20 +08:00
Lin Jen-Shin 143fc48aba Add RequestStoreWrap to cache via RequestStore
I don't like the idea of `RequestStore` at all, because it's just a
global state which shouldn't be used at all. But we have a number of
places calling `ProtectedBranch.protected?` and `ProtectedTag.protected?`
in a loop for the same user, project, and ref whenever we're checking
against if the jobs for a given pipeline is accessible for a given user.
This means we're effectively making N queries for the same thing over
and over.

To properly fix this, we need to change how we check the permission,
and that could be a huge work. To solve this quickly, adding a cache
layer for the given request would be quite simple to do.

We're already doing this in Commit#author, and this is extending that
idea and make it generalized.
2017-07-17 23:24:46 +08:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Bob Van Landuyt 019b06b9d2 Load a project's CI status in batch from redis 2017-04-26 12:04:22 +00:00
Bob Van Landuyt 516a405eb2 Take the ref of a pipeline into account when caching status 2017-04-07 17:24:11 +02:00
Bob Van Landuyt 02072e17ab Rename `ProjectBuildStatus` -> `ProjectPipelineStatus` 2017-04-07 17:24:11 +02:00
Bob Van Landuyt a6d313001a Wrap updating of cache after pipeline transition in class method 2017-04-07 17:24:11 +02:00
Bob Van Landuyt 9082d1e046 Rename Ci::PipelineStatus -> Ci::ProjectBuildStatus 2017-04-07 17:24:11 +02:00