-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laravel cache adapter #32
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping me when tests have been added 👍
src/Adapters/LaravelCacheAdapter.php
Outdated
|
||
private const CACHE_KEY_SUFFIX = '_METRICS'; | ||
|
||
private const STORES = [Gauge::TYPE, Counter::TYPE, Histogram::TYPE, Summary::TYPE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor this to a regular array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact the rest of the const, can be refactored the regular protected properties as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by regular array?
as a property instead of a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nitpicks
@@ -43,4 +43,17 @@ | |||
* Allow storage to be wiped after a render of data in metrics controller. | |||
*/ | |||
'wipe_storage_after_rendering' => false, | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this doc block smaller. Only 1 or 2 sentences. Move the rest of the explanation to a new section in the readme.
|
||
class LaravelCacheAdapter extends InMemory | ||
{ | ||
protected string $cacheKeyPrefix = 'PROMETHEUS_'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make these values less "screamy" by using a lowercase value.
|
||
protected function cacheKey(string $type): string | ||
{ | ||
return $this->cacheKeyPrefix.$type.$this->cacheKeySuffix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use string interpolation here.
This PR adds a laravel cache adapter, to leverage all of the laravel cache storage implementations.
I manually tested it with the database, redis, file and array drivers.
I'll provide programmatic tests asap, I just need to read up on Pest first.