samuelnogueira / cache-datastore-newrelic
Reports calls to any psr/simple-cache or psr/cache implementation as a custom New Relic Datastore
Installs: 4 497
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ~8.0.0 || ~8.1.0
- ext-newrelic: >=7.5.0
- psr/cache: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- phpstan/phpstan: 1.4.6
- phpstan/phpstan-strict-rules: 1.1.0
- phpunit/phpunit: 9.5.13
- squizlabs/php_codesniffer: 3.6.2
- symfony/cache: 6.0.8
- thecodingmachine/phpstan-strict-rules: 1.0.0
Provides
README
Reports 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') );