Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:28:07+00:00 2026-06-06T18:28:07+00:00

I have a repository where I’m trying to set up result caching. I’ve only

  • 0

I have a repository where I’m trying to set up result caching. I’ve only been able to find a single example online for how to do this… but when I implement the example in one of my repositories I get an error.
I am using APC for my caching and have enabled query caching to use APC in my config.yml file. I’ve allocated 512M to APC and its only using 50M currently (23M of this is for this single failed cache entry)

Here’s the repository code I have:

class AchievementRepository extends EntityRepository
{
    function findAchievementsByCategory($categoryObj)
    {
        $em=$this->getEntityManager()->createQuery("SELECT a FROM FTWGuildBundle:Achievement a where a.category=:category order by a.title")
            ->setParameter('category',$categoryObj);
        $em->useResultCache(true,3600,'findAchievementsByCategory');
        $result=$em->getResult();
        return $result;
    }
}

And when this is executed I get the following error

Notice: apc_store() [<a href='function.apc-store'>function.apc-store</a>]: &quot;type&quot; returned as member variable from __sleep() but does not exist in /data/www/ftw2/Symfony/vendor/doctrine-common/lib/Doctrine/Common/Cache/ApcCache.php line 80 

When I look in my apc.php file to see what is cached, I find my cache entry in the user cache section with a stored value of

Fatal error:  Nesting level too deep - recursive dependency? in /data/www/localhost/apc.php on line 1000

Can anyone provide me with some direction as to where I have gone wrong?

There are a couple columns in this entity which are ManyToOne, do I need to disable lazy load on this query for this to work? If so… how?
EDIT: I enabled eager load by adding ,fetch=”EAGER” to my ManyToOne mapping… no apples 🙁

EDIT #2: ANSWERED – Working class code (note, all properties of the entity class (Achievement) have been changed to protected)

class AchievementRepository extends EntityRepository
{
    function findAchievementsByCategory($categoryObj)
    {
        $em=$this->getEntityManager()->createQuery("SELECT a FROM FTWGuildBundle:Achievement a where a.category=:category order by a.title")
            ->setParameter('category',$categoryObj);
        $em->useResultCache(true,3600,'findAchievementsByCategory');
        $result=$em->getArrayResult();
        return $result;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:28:08+00:00Added an answer on June 6, 2026 at 6:28 pm

    When Doctrine caches an entity, it saves the serialized state of it. The problem is, private properties (the default visibility when generated by Doctrine) cannot be serialized. To fix this, you have to make your entity properties protected. More info: http://doctrine-orm.readthedocs.org/en/2.0.x/reference/working-with-objects.html#merging-entities

    The other thing is a know issue that is (finally) fixed in Doctrine version 2.2, which will be in Symfony 2.1. If you can’t upgrade for some reason, the only way to cache associations is to use getArrayResult instead of populating entities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) {
I have following repository: public function findClassPhotoByPath($path) { return $this->getEntityManager() ->createQuery('SELECT p FROM KSRGalleryBundle:Photo
I have a repository that looks something like this: foo/ subrepo/ a_file_in_subrepo another.ext unrelated_file
I have repository class in asp.net mvc which has this, public Material GetMaterial(int id)
I have repository configured like this: \Util_1 \branches \tags \trunk \Util_2 \branches \tags \trunk
Hi have a repository checkout (SVN) which has been heavily modified by a team
I have a repository whose layout is like this: trunk/ projectA projectB branches/ projectA-1.0
I have a repository that is running subversion. Some users have not been committing
I have a repository on github, say testrepo. Now I'd like to set up
I have a repository set up on a server running Git, the repository has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.