Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cachedbuzz Laravel Package

dozoisch/cachedbuzz

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require dozoisch/cachedbuzz:dev-master
    

    Add the bundle to app/AppKernel.php:

    new Dozoisch\CachedBuzzBundle\DozoischCachedBuzzBundle(),
    
  2. First Use Case: Replace buzz service calls with dozoisch_cached_buzz.client in your services. Example:

    $client = $this->get('dozoisch_cached_buzz.client');
    $response = $client->get('https://api.example.com/data');
    
  3. Default Configuration: The bundle auto-configures with APC caching (falls back to default if APC unavailable). No manual config needed for basic use.


Implementation Patterns

Workflows

  1. Service Replacement: Replace buzz.client with dozoisch_cached_buzz.client in your controllers/services. The API remains identical to Buzz.

  2. Cache Invalidation: Use Symfony’s cache system to invalidate entries:

    $this->get('dozoisch_cached_buzz.cache')->delete('https://api.example.com/data');
    
  3. Custom Cache/Validator: Override defaults via config (app/config/config.yml):

    dozoisch_cached_buzz:
        cache: 'cache.app'  # Use Symfony's cache service
        validator: 'my_custom_validator'
    
  4. Integration with HTTP Clients: Use with Guzzle-like patterns:

    $response = $client->request('GET', 'https://api.example.com/data', [
        'headers' => ['Accept' => 'application/json']
    ]);
    

Common Patterns

  • Cache Key Generation: The bundle auto-generates keys from URLs + query params. Override via validator if needed.
  • Conditional Caching: Disable caching for specific requests:
    $client->get('https://api.example.com/uncached', ['cache' => false]);
    

Gotchas and Tips

Pitfalls

  1. APC Dependency: Default cache uses APC. If APC is unavailable, the bundle fails silently (no fallback). Specify a custom cache (e.g., cache.app) in config to avoid this.

  2. Cache Key Collisions: Default key generation may conflict for similar URLs. Extend the validator to customize keys:

    services:
        my_validator:
            class: AppBundle\Validator\CustomCachedBuzzValidator
            arguments: ['@dozoisch_cached_buzz.client']
    
  3. Configuration Overrides: Ensure dozoisch_cached_buzz config is merged correctly. Use parameters or imports in config.yml if needed.

Debugging

  • Cache Misses: Check logs for CACHE_MISS events. Enable Symfony’s cache debug toolbar for visibility.
  • Validator Errors: If responses aren’t cached, verify the validator service is properly implemented (must extend Dozoisch\CachedBuzzBundle\Validator\CachedBuzzValidatorInterface).

Extension Points

  1. Custom Cache Drivers: Implement Psr\Cache\CacheItemPoolInterface and reference it in config:

    dozoisch_cached_buzz:
        cache: 'my_cache_service'
    
  2. Request/Response Filtering: Extend the validator to modify cache logic:

    class MyValidator implements CachedBuzzValidatorInterface {
        public function isCacheable(RequestInterface $request) {
            return $request->getMethod() !== 'POST'; // Skip POST requests
        }
    }
    
  3. Event Listeners: Subscribe to cachedbuzz.response events to post-process responses before caching:

    services:
        my_cachedbuzz_listener:
            class: AppBundle\EventListener\CachedBuzzListener
            tags:
                - { name: kernel.event_listener, event: cachedbuzz.response, method: onResponse }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log