Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-ALPHA3
    • Component/s: None
    • Labels:
      None

      Description

      We need better control for setting the hash/key for resultset cache entries. Then provide a way to clear these cache entries.

      http://trac.doctrine-project.org/ticket/2042

      $temp = Doctrine_Query::create() 
      ->from('Profile p') 
      ->where('p.id=?', $o) 
      ->setHydrationMode(Doctrine::HYDRATE_ARRAY) 
      ->useResultCache(true, 3600, 'product_cache') // custom tag 
      ->execute(); 
      
      $temp = Doctrine_Query::create() 
      ->from('Model m') 
      ->setHydrationMode(Doctrine::HYDRATE_ARRAY) 
      ->useResultCache(true, 3600, 'product_cache') // custom tag 
      ->execute(); 
      
      $temp = Doctrine_Query::create() 
      ->from('News n') 
      ->setHydrationMode(Doctrine::HYDRATE_ARRAY) 
      ->useResultCache(true, 3600, 'news_cache') // custom tag 
      ->execute(); 
      

      and now

      $conn  = Doctrine_Manager::getConnection('sqlite_cache_connection'); 
      $cacheDriver = new Doctrine_Cache_Db(array('connection' => $conn, 
      'tableName' => 'cache')); 
      
      $cacheDriver->deleteByTag('product_cache');
      

        Issue Links

          Activity

          Hide
          Michael Roterman added a comment - - edited

          Would an use case as followed be also considered?

          $temp = Doctrine_Query::create()
          ->from('Model m')
          ->setHydrationMode(Doctrine::HYDRATE_ARRAY)
          ->useResultCache(true, 3600,array('product_cache', 'product_clean')) // custom array with tags
          ->execute();

          So multiple tags could be used as "labels" for an cache instance?

          Show
          Michael Roterman added a comment - - edited Would an use case as followed be also considered? $temp = Doctrine_Query::create() ->from('Model m') ->setHydrationMode(Doctrine::HYDRATE_ARRAY) ->useResultCache(true, 3600,array('product_cache', 'product_clean')) // custom array with tags ->execute(); So multiple tags could be used as "labels" for an cache instance?
          Hide
          Jonathan H. Wage added a comment -

          Not really. The cache drivers only have the ability to store key => value pairs so we're limited on what we can provide in Doctrine natively.

          Show
          Jonathan H. Wage added a comment - Not really. The cache drivers only have the ability to store key => value pairs so we're limited on what we can provide in Doctrine natively.
          Hide
          Miloslav "adrive" Kmet added a comment -

          I think, that each driver should store also cache metadata (that's the behaviour of symfony's cache system)..

          In the cache should be sotred also the cache_info key that should be an array of cached keys each index of an array should be the tag name and each tagname should contain multiple cached_keys.

          {{

          { $cacheInfo = array( 'product_cache' => array('sql_1_key', 'sql_1_key_paged', 'sql_2_key', 'etc' ,'etc'), 'brands_cache' => array('sq_1_key', 'sql_3_key') ); }

          }}

          The deleteByTag method should also be able to compare the tag against regular expression...

          Show
          Miloslav "adrive" Kmet added a comment - I think, that each driver should store also cache metadata (that's the behaviour of symfony's cache system).. In the cache should be sotred also the cache_info key that should be an array of cached keys each index of an array should be the tag name and each tagname should contain multiple cached_keys. {{ { $cacheInfo = array( 'product_cache' => array('sql_1_key', 'sql_1_key_paged', 'sql_2_key', 'etc' ,'etc'), 'brands_cache' => array('sq_1_key', 'sql_3_key') ); } }} The deleteByTag method should also be able to compare the tag against regular expression...
          Hide
          Jonathan H. Wage added a comment -

          Please remember we are limited by what the cache drivers can do. We can only store key => value pairs and can only select and delete one key at a time. No deleting by regular expression or anything like that. All your above suggestions are great idealistically but are impossibly to implement so we need to keep that in mind.

          Show
          Jonathan H. Wage added a comment - Please remember we are limited by what the cache drivers can do. We can only store key => value pairs and can only select and delete one key at a time. No deleting by regular expression or anything like that. All your above suggestions are great idealistically but are impossibly to implement so we need to keep that in mind.
          Hide
          Miloslav "adrive" Kmet added a comment -

          Jon, have you ever seen the sf*Cache classes?

          Please, look at http://trac.symfony-project.org/browser/branches/1.2/lib/cache/sfMemcacheCache.class.php especially on methods set, setCacheInfo, removePattern. I know that the drivers doesn't have functions for regexp searching. Therefor I am suggesting to store also the cache info as symfony does.

          I will create some patches in a few days...

          Show
          Miloslav "adrive" Kmet added a comment - Jon, have you ever seen the sf*Cache classes? Please, look at http://trac.symfony-project.org/browser/branches/1.2/lib/cache/sfMemcacheCache.class.php especially on methods set, setCacheInfo, removePattern. I know that the drivers doesn't have functions for regexp searching. Therefor I am suggesting to store also the cache info as symfony does. I will create some patches in a few days...
          Hide
          Jonathan H. Wage added a comment -

          Ok. I understand now. i think we can implement something similar where we just maintain our own list/index of all the keys we've cached so that we can perform regex deletions. I have some patches that I will commit today because I want to release alpha3 asap.

          Show
          Jonathan H. Wage added a comment - Ok. I understand now. i think we can implement something similar where we just maintain our own list/index of all the keys we've cached so that we can perform regex deletions. I have some patches that I will commit today because I want to release alpha3 asap.
          Hide
          Jonathan H. Wage added a comment -

          I committed some changes that now allow you to delete by regular expressions. We need to test this asap so that I can release alpha3 tomorrow morning.

          Show
          Jonathan H. Wage added a comment - I committed some changes that now allow you to delete by regular expressions. We need to test this asap so that I can release alpha3 tomorrow morning.

            People

            • Assignee:
              Jonathan H. Wage
              Reporter:
              Jonathan H. Wage
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: