PHPackages                             intaro/memcached-tags-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. intaro/memcached-tags-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

intaro/memcached-tags-bundle
============================

Native query builder for doctrine

v0.2(11y ago)055MITPHPPHP &gt;=5.3.0

Since Aug 14Pushed 11y ago1 watchersCompare

[ Source](https://github.com/1on/memcached-tags-bundle)[ Packagist](https://packagist.org/packages/intaro/memcached-tags-bundle)[ RSS](/packages/intaro-memcached-tags-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

IntaroMemcachedTagsBundle
=========================

[](#intaromemcachedtagsbundle)

About
-----

[](#about)

The Memcached Tags Bundle allows to add tags for doctrine query result cache and clear result cache by tags. Based on [LswMemcacheBundle](https://github.com/LeaseWeb/LswMemcacheBundle)

Installation
------------

[](#installation)

Require the bundle in your composer.json file:

```
{
    "require": {
        "intaro/memcached-tags-bundle": "dev-master"
    }
}
```

Register the bundle:

```php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        new Intaro\MemcachedTagsBundle\IntaroMemcachedTagsBundle(),
    );
}
```

Install the bundle:

```
$ composer update intaro/memcached-tags-bundle
```

## Usage ##

### Query ###

Create new Query with necessary cache life time and cache tags:

```php
    $em = $container->get('doctrine')->getManager();
    $em->createQuery('SELECT book FROM AcmeHelloBundle:Book book', 3600, [
        'Acme\HelloBundle\Entity\Book'
    ]);
```

### NativeQuery ###

NativeQuery with cache tags works same as Query.

```php
    $em = $container->get('doctrine')->getManager();
    $em->createNativeQuery('SELECT * FROM book', $rsm, 3600, [
        'Acme\HelloBundle\Entity\Book'
    ]);
```

### QueryBuilder ###

```php
    $em = $container->get('doctrine')->getManager();
    $builder = $em->createQueryBuilder()
        ->select('book')->from('AcmeHelloBundle:Book', 'book')
        ->useResultCache(true, 3600) //enable result cache and set cache life time
        ->setCacheTags(['Acme\HelloBundle\Entity\Book'])
        ->join('book.author', 'author')
        ->addCacheTag('Acme\HelloBundle\Entity\Author');

    if ($disableTags) {
        $builder->clearCacheTags();
    }

    $builder->getQuery()->getResult();
```

### Clear cache ###

```php
    $em = $container->get('doctrine')->getManager();
    $em->getRepository('AcmeHelloBundle:Book')->clearEntityCache();
    // or
    $em->tagsClear('Acme\HelloBundle\Entity\Book');

    $book = $em->getRepository('AcmeHelloBundle:Book')->find($id);
    $em->getRepository('AcmeHelloBundle:Book')->clearEntityCache($book->getId());
    // or
    $em->tagsClear('Acme\HelloBundle\Entity\Book[id="' . $book->getId() . '"]');
```

On entity insertions, update and deletes automatically clears cache for changed class names and changed entity id.

```php
    $em = $container->get('doctrine')->getManager();
    $book = $em->getRepository('AcmeHelloBundle:Book')->find(25);
    $book->setName('New book');
    $em->merge($book);
    $em->flush();
    // Tags Acme\HelloBundle\Entity\Book and Acme\HelloBundle\Entity\Book[id="25"] are cleared
```

### ManyToOne association cache ###

```php
    use Intaro\MemcachedTagsBundle\Doctrine\Annotation\AssociationCache;

    /**
     * @ORM\Entity
     * @ORM\Table(name="shelf")
     * @AssociationCache(lifetime=100)
     */
    class Shelf
    {
        ...
    }

    /**
     * @ORM\Entity
     * @ORM\Table(name="shelf")
     * @AssociationCache(lifetime=100, tags={"Acme\HelloBundle\Entity\Author", "Acme\HelloBundle\Entity\Book"})
     */
    class Author
    {
        ...
    }

```

```php
    $em = $container->get('doctrine')->getManager();
    $book = $em->getRepository('AcmeHelloBundle:Book')->find(25);
    $shelf = $book->getShelf();
    // Cache with tag Acme\HelloBundle\Entity\Shelf[id="13"] will be loaded
```

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

4289d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/455711b6a0784e7fa0097f52b71166a1c35d7c2372c3a03f6ec21e243de7fa73?d=identicon)[kruglov](/maintainers/kruglov)

---

Top Contributors

[![1on](https://avatars.githubusercontent.com/u/2292168?v=4)](https://github.com/1on "1on (2 commits)")

---

Tags

doctrineSymfony2memcachedtags

### Embed Badge

![Health badge](/badges/intaro-memcached-tags-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/intaro-memcached-tags-bundle/health.svg)](https://phpackages.com/packages/intaro-memcached-tags-bundle)
```

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[data-dog/audit-bundle

Audit bundle for symfony2 and doctrine orm, logs any database change

141901.7k1](/packages/data-dog-audit-bundle)[webonaute/doctrine-fixtures-generator-bundle

Generate Fixture from your existing data in your database. You can specify the Entity name and the IDs you want to import in your fixture.

67184.1k](/packages/webonaute-doctrine-fixtures-generator-bundle)[data-dog/pager-bundle

Paginator bundle for symfony2 and doctrine orm, allows customization with filters and sorters

11103.5k7](/packages/data-dog-pager-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
