Loading ...
Sorry, an error occurred while loading the content.

Re: [Cheetahtemplate-discuss] Caching

Expand Messages
  • Stuart Clarke
    Thanks very much for the reply Tavis. I m sorry I didn t notice it until now. Comments below... ... *** Hmmm... TG will have multiple threads, no doubt. But
    Message 1 of 4 , Nov 3, 2006
    • 0 Attachment
      Thanks very much for the reply Tavis. I'm sorry I didn't notice it
      until now.

      Comments below...

      > I've got a few questions before I answer your question about usage patterns:
      > - What do you plan on caching: fragments within cheetah templates, the complete
      > output of cheetah templates or the entire page including stuff not handled by
      > Cheetah?

      *** Fragments.

      > - Are you going to be running multiple instances of turbogears on each node?

      *** Hmmm... TG will have multiple threads, no doubt. But I won't
      actually be running multiple instances of the TG "system" on a given
      node. Regardless of where they're situated, however, all TG instances
      must remain "in-sync" with one another, and not maintain their own
      caches in their own little worlds.

      > - Are you going to have 1 shared memcached daemon or one per node?

      *** I will have any number of memcached daemons, and each system
      instance will need to use all of them (via the server list one can
      provide in creating a connection with python-memcached). This will
      provide me with the best caching bandwidth and space that I could hope
      for.

      > - Are you also planning on implementing HTTP cache negotiation with etags,
      > conditional HTTP 304 responses, etc.?

      *** Not sure about these things. Are they means of the client
      controlling whether they should be given cached content or fresh
      content? Such things could be useful, however I was planning to add a
      simple &cache=true/false to my URLs. Which I would eventually translate
      into a directive for Cheetah to cache or not.

      > Regarding cache IDs, you need to understand some of Cheetah's caching internals
      > before they will make sense in the context of Memcahed:
      >
      > - each #cache ... #end cache block is represented by a CacheRegion object. You
      > can provide an ID for it like this '#cache id="foo"' or Cheetah will provide a
      > random one.
      >
      > - each CacheRegion has 1 or more CacheItem objects, depending on the use of the
      > 'varyBy' argument. Each CacheItem has an ID, which is the same as the
      > CacheRegion's ID if you're *not* using varyBy, or is the output of varyBy. If
      > varyBy is used, the number of CacheItems will grow as varyBy returns new values.
      >
      > - varyBy can be any python expression that can be converted into a string via
      > str():
      > varyBy=func(), varyBy=$var, etc.
      >
      > - CacheItems are kept in a CacheStore. See Cheetah/src/CacheStore.py. The
      > default is MemoryCacheStore. MemcachedCacheStore is the only alternative at
      > this stage.
      >
      > - CacheRegions are responsible for creating CacheItems, storing them in the
      > CacheStore and retrieving them.
      >
      > - The keys used by the CacheStore are a string in the following format:
      > 'templatePrefix:cacheRegionId:md5HashOfCacheItemId', where templatePrefix comes
      > from Template._getCacheStoreIdPrefix().

      *** I've looked through the code (2.0rc7). I can see where the cache
      store is created in _getCacheStore in Template.py. And that I can
      uncomment a line earlier in that file, to change my preferred cache
      store class to MemcachedCacheStore.

      I notice, however, that no arguments are passed to the cache store
      constructor. Which seems bizarre in the context of memcached, since
      it's designed to be distributed across multiple servers, with the server
      list passed to the python-memcached library on construction. Which is
      how I want to use it.

      So what should I do from here? Am I missing something, or do I need to
      start hacking at Template.py and adjust it to my needs?

      Thanks for your help,

      Stuart


      -------------------------------------------------------------------------
      Using Tomcat but need to do more? Need to support web services, security?
      Get stuff done quickly with pre-integrated technology to make your job easier
      Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
      http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Stuart Clarke
      One more thing... ... *** So if I have multiple instances TG running, will each of them create different (random) cacheRegionId s for a given chunk of
      Message 2 of 4 , Nov 3, 2006
      • 0 Attachment
        One more thing...

        > - The keys used by the CacheStore are a string in the following format:
        > 'templatePrefix:cacheRegionId:md5HashOfCacheItemId', where templatePrefix comes
        > from Template._getCacheStoreIdPrefix().

        *** So if I have multiple instances TG running, will each of them create
        different (random) cacheRegionId's for a given chunk of template? Even
        though the template-chunks are actually the same code? That kinda
        sucks, since I need my TG instances to be able to share the template
        caches amongst themselves.

        To avoid this, do I therefore need to manually assign IDs to all of my
        cache regions, and to make sure they don't conflict with one another?

        That's not good :(

        Stuart


        -------------------------------------------------------------------------
        Using Tomcat but need to do more? Need to support web services, security?
        Get stuff done quickly with pre-integrated technology to make your job easier
        Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
        http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      Your message has been successfully submitted and would be delivered to recipients shortly.