2017 © Pedro Peláez
 

symfony-bundle update-tracker-bundle

QIMNET Update tracker bundle

image

qimnet/update-tracker-bundle

QIMNET Update tracker bundle

  • Thursday, June 13, 2013
  • by qimnet
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

Qimnet\UpdateTrackerBundle

This bundle is used to track updates on entites and cache results client side or server side according to the update times., (*1)

Configuration

An UpdateTracker entity has to be added to the project to use the bundle., (*2)

The following code can be used :, (*3)

<?php
namespace ACME\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

use Qimnet\UpdateTrackerBundle\Entity\UpdateTracker as BaseUpdateTracker;

/**
 * @ORM\Entity
 */
class UpdateTracker extends BaseUpdateTracker
{

}

The name of the entity should then be added to your config.yml file :, (*4)

qimnet_update_tracker:
    entity_name: 'ACME\MyBundle\Entity\UpdateTracker'

Tracking entity changes

To track the changes of a given entity, you have two choices :, (*5)

  • use the Qimnet\UpdateTrackerBundle\Annotation\TrackUpdate annotation on your entity class
  • implement Qimnet\UpdateTrackerBundle\UpdateTracker\TrackUpdateInterface in your entity class

The changes can then be tracked using the qimnet.update_tracker.manager service., (*6)

Using HTTP cache validation

To generate HTTP responses and use HTTP cache validation, use the qimnet.update_tracker.http_cached_response_factory service :, (*7)

<?php
namespace ACME\MyBundle\Controller;
class MyController
{
    public function myAction() 
    {
        $response = $this->get('qimnet.update_tracker.http_cached_response_factory')
            ->generate('my_namespace');
        if ($response->isNotModified($this->getRequest())) {
            return $response;
        }
        // Fetch content
        $response->setContent('Some content');
        return $response;
    }
}

Using timestamps in Urls

Timestamped URL are useful for using HTTP cache expire headers with dynamic content. This can be useful for :, (*8)

  • content which can afford to have a changing URL
  • ESI

To use timestamped URLs in your twig templates, use the timestamped_path, timestamped_url and timestamped_controller functions., (*9)

Here is an example of this type of caching strategy with an ESI :, (*10)

namespace ACME\MyBundle\Controller;
class MyController
{
    /**
    *   Every variation of the output of this method should update the 
    *  "my_update_tracker" UpdateTracker.
    * 
    *   @Cache(expires="+1year")
    **/
    public function esiAction() {
        ...
        return $response;
    }
}
    {# /ACME/MyBundle/Resources/views/layout.html.twig #}
    ...
    {% render_esi(timestamped_url("acme_mybundle_mycontroller_esi", {}, "my_update_tracker")) %}
    ...

Using server side caching

To use server side caching, enable the cache manager in your configuration file :, (*11)

qimnet_update_tracker:
    cache_manager:

        # True to enable the cache manager.
        enabled:              true

You can then request cached object using the qimnet.update_tracker.cache_manager service :, (*12)

<?php
namespace ACME\MyBundle\Controller;
use Symfony\Component\HttpFoundation\Response;

class MyController
{
    public function myAction($id)
    {
        $content = $this->get('qimnet.update_tracker.cache_manager')
            ->getObject('my_namespace', 'my_object/' . $id, function(){
                //Fetch the content and return it
                return 'Some content';
            })
        return new Response($content);
    }
}

You can also render cached fragments directly from yout templates by using the render tag with the cache strategy :, (*13)

{{ render(controller("MyBundle:MyController:myAction"), { strategy: "cache", "updateTrackerName": "my_update_tracker", ttl: 120 }) }}

Cache entries are automatically deleted when the corresponding update tracker namespace is changed., (*14)

The Versions

13/06 2013

dev-master

9999999-dev http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

05/06 2013

v1.5.2

1.5.2.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

28/04 2013

v1.5.1

1.5.1.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

12/04 2013

v1.5.0

1.5.0.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

25/03 2013

v1.4.2

1.4.2.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

22/03 2013

v1.4.1

1.4.1.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

15/03 2013

v1.4.0

1.4.0.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

12/03 2013

v1.3.4

1.3.4.0 http://qimnet.com

QIMNET Update tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

cache http

11/03 2013

v1.3.3

1.3.3.0 http://qimnet.com

QIMNET HTTP bundle (alpha)

  Sources   Download

MIT

The Requires

 

The Development Requires

http

08/03 2013

v1.3.2

1.3.2.0 http://qimnet.com

QIMNET Update Tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

http

08/03 2013

v1.3.1

1.3.1.0 http://qimnet.com

QIMNET Update Tracker bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

http

08/03 2013

v1.3.0

1.3.0.0 http://qimnet.com

QIMNET HTTP bundle (alpha)

  Sources   Download

MIT

The Requires

 

The Development Requires

http

07/03 2013

v1.2.0

1.2.0.0 http://qimnet.com

QIMNET HTTP bundle (alpha)

  Sources   Download

MIT

The Requires

 

http

28/02 2013

v1.1.0

1.1.0.0 http://qimnet.com

QIMNET HTTP bundle (alpha)

  Sources   Download

MIT

The Requires

 

http