samuelnogueira / cache-datastore-newrelic
Reports calls to any psr/simple-cache or psr/cache implementation as a custom New Relic Datastore
Installs: 8 899
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- ext-newrelic: >=7.5.0
- psr/cache: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- phpstan/phpstan: 1.10.66
- phpstan/phpstan-strict-rules: 1.5.2
- phpunit/phpunit: 9.6.16
- squizlabs/php_codesniffer: 3.9.1
- symfony/cache: 6.0.19
- thecodingmachine/phpstan-strict-rules: 1.0.0
Provides
README
Report calls to any psr/simple-cache
or psr/cache
implementation as a custom New Relic Datastore.
Uses the newrelic_record_datastore_segment function to record calls to an unsupported database.
Requirements
Requires New Relic PHP Agent version >= 7.5.0.
Usage
Decorate your existing:
\Psr\Cache\CacheItemPoolInterface
\Psr\SimpleCache\CacheInterface
with respectively:
\Samuelnogueira\CacheDatastoreNewrelic\CacheItemPoolDecorator
\Samuelnogueira\CacheDatastoreNewrelic\SimpleCacheDecorator
Example with PSR-6: Caching Interface:
use Psr\Cache\CacheItemPoolInterface; use Samuelnogueira\CacheDatastoreNewrelic\CacheItemPoolDecorator; use Samuelnogueira\CacheDatastoreNewrelic\DatastoreParams; /** @var CacheItemPoolInterface $cache */ return new CacheItemPoolDecorator( $cache, // your cache adapter new DatastoreParams('My Database Product'), );
Example with PSR-16: Common Interface for Caching Libraries (aka Simple Cache):
use Psr\SimpleCache\CacheInterface; use Samuelnogueira\CacheDatastoreNewrelic\SimpleCacheDecorator; use Samuelnogueira\CacheDatastoreNewrelic\DatastoreParams; /** @var CacheInterface $cache */ return new SimpleCacheDecorator( $cache, // your cache adapter new DatastoreParams('My Database Product'), );