locked
ability to use cache when retrieving entities from table storage RRS feed

  • Question

  • I'm looking to improve performance a bit (and reduce cost, somewhat) when accessing table storage.  Specifically, I would like the ability to retrieve entities from cache when they are available and to retrieve them table storage in other cases.

    So, when I am fetching a specific entity (where Partition & Row keys are known) it is pretty straight forward for me to check cache first.  However, in the cases where I have to query the table is there a way to mix cache and table storage when retrieving indvidual entities?

    I had hoped that the query would return partition/row key pairs which were used when fetching the full entity -- but, don't see that.

    So, any thoughts?

    marc

    Tuesday, August 10, 2010 1:09 AM

Answers

  • Hello, can you elaborate? Today we don't support distributed cache out of box. But simple in-memory cache (like the standard ASP.NET cache) works fine in Windows Azure. So you can already do something like:

    if (Cache["myitem"] != null)

    {

    return Cache["myitem"];

    }

    else

    {

    return QueryTable();

    }

     

    The only limitation is each instance maintains its own cache. So if the item is already in cache on instance 1, and the web request goes to instance 2, you still need a round trip to the table service.

    Or do you mean you only store partition/row keys in the cache? In this case, you still need a round trip to table storage if you want to retrieve the entire entity.

    If you mean you want to perform a query against table storage that only returns partition/row keys, that's not supported today.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 5:40 AM
  • In addition to that you can use the internal ip endpoint to broadcast cache coherency messages to the other running instances. Not a distributed cache, but a survival tool.

     

    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 2:55 PM
  • Mark,

    Are you looking for metadata in order to synthesize a key or are you looking for a pattern to compose instances on the fly where some data may be cached and some may be retrieved from a durable store?

    In general, I like the pattern where you compose instances in multiple layers - and at each layer you can potentially leverage the cache. I can whip up a code example if it would be useful.

    - mw
    http://blogs.neudesic.com/author/mickey.williams.aspx

    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 9:08 PM

All replies

  • Hello, can you elaborate? Today we don't support distributed cache out of box. But simple in-memory cache (like the standard ASP.NET cache) works fine in Windows Azure. So you can already do something like:

    if (Cache["myitem"] != null)

    {

    return Cache["myitem"];

    }

    else

    {

    return QueryTable();

    }

     

    The only limitation is each instance maintains its own cache. So if the item is already in cache on instance 1, and the web request goes to instance 2, you still need a round trip to the table service.

    Or do you mean you only store partition/row keys in the cache? In this case, you still need a round trip to table storage if you want to retrieve the entire entity.

    If you mean you want to perform a query against table storage that only returns partition/row keys, that's not supported today.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 5:40 AM
  • In addition to that you can use the internal ip endpoint to broadcast cache coherency messages to the other running instances. Not a distributed cache, but a survival tool.

     

    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 2:55 PM
  • Mark,

    Are you looking for metadata in order to synthesize a key or are you looking for a pattern to compose instances on the fly where some data may be cached and some may be retrieved from a durable store?

    In general, I like the pattern where you compose instances in multiple layers - and at each layer you can potentially leverage the cache. I can whip up a code example if it would be useful.

    - mw
    http://blogs.neudesic.com/author/mickey.williams.aspx

    • Marked as answer by Yi-Lun Luo Monday, August 16, 2010 9:33 AM
    Tuesday, August 10, 2010 9:08 PM