Programmatically Clear Metadata Cache?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Programmatically Clear Metadata Cache?

JBChristy
I've just up automatic (mem)caching of all Zend_DB_Table's. From time to time, of course, the metadata changes. We do this in our production environment by running sql scripts that add / drop / change columns as necessary. I need some programmatic way to expire the metadata cache after the sql runs, and no later than when updated code goes live, which is a matter of minutes. I can't just wait til it times out.

I've dug into Zend 1.11 Zend_Db_Table_Abstract, and the memcache key is an md5 encoding of an optional port, optional host, dbname, schema name and table name. There does not appear to be member function to expire the cache, nor even a function to return the md5 encoded key so I can delete it manually.

How are we supposed to clear the metadata cache when the metadata changes?

Thanks in advance for your help!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Programmatically Clear Metadata Cache?

umpirsky
You can set table metadata cache with

$cache = Zend_Cache::factory(...);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);

and clear cache with

$cache->clean(...);

when the metadata changes.

---
Regards,
Saša Stamenković


On Mon, Mar 7, 2011 at 10:40 PM, JBChristy <[hidden email]> wrote:

> I've just up automatic (mem)caching of all Zend_DB_Table's. From time to
> time, of course, the metadata changes. We do this in our production
> environment by running sql scripts that add / drop / change columns as
> necessary. I need some programmatic way to expire the metadata cache after
> the sql runs, and no later than when updated code goes live, which is a
> matter of minutes. I can't just wait til it times out.
>
> I've dug into Zend 1.11 Zend_Db_Table_Abstract, and the memcache key is an
> md5 encoding of an optional port, optional host, dbname, schema name and
> table name. There does not appear to be member function to expire the
> cache,
> nor even a function to return the md5 encoded key so I can delete it
> manually.
>
> How are we supposed to clear the metadata cache when the metadata changes?
>
> Thanks in advance for your help!
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Programmatically-Clear-Metadata-Cache-tp3340068p3340068.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Programmatically Clear Metadata Cache?

JBChristy
Thanks for your helpful reply. Hopefully I can figure out how to call that
$table->getDefaultMetadataCache()->clean() at the right time / in the right
context.

-JB





________________________________
From: Саша Стаменковић <[hidden email]>
To: JBChristy <[hidden email]>
Cc: [hidden email]
Sent: Mon, March 7, 2011 10:57:20 PM
Subject: Re: [fw-db] Programmatically Clear Metadata Cache?

You can set table metadata cache with

$cache = Zend_Cache::factory(...);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);

and clear cache with

$cache->clean(...);

when the metadata changes.

---
Regards,
Saša Stamenković



On Mon, Mar 7, 2011 at 10:40 PM, JBChristy <[hidden email]> wrote:

I've just up automatic (mem)caching of all Zend_DB_Table's. From time to

>time, of course, the metadata changes. We do this in our production
>environment by running sql scripts that add / drop / change columns as
>necessary. I need some programmatic way to expire the metadata cache after
>the sql runs, and no later than when updated code goes live, which is a
>matter of minutes. I can't just wait til it times out.
>
>I've dug into Zend 1.11 Zend_Db_Table_Abstract, and the memcache key is an
>md5 encoding of an optional port, optional host, dbname, schema name and
>table name. There does not appear to be member function to expire the cache,
>nor even a function to return the md5 encoded key so I can delete it
>manually.
>
>How are we supposed to clear the metadata cache when the metadata changes?
>
>Thanks in advance for your help!
>
>--
>View this message in context:
>http://zend-framework-community.634137.n4.nabble.com/Programmatically-Clear-Metadata-Cache-tp3340068p3340068.html
>
>Sent from the Zend DB mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Programmatically Clear Metadata Cache?

umpirsky
You can save cache to registry or get it from bootstrap as it is the same
instance as in table if that comes handy for you.
---
Regards,
Saša Stamenković


On Tue, Mar 8, 2011 at 7:49 PM, JB Christy <[hidden email]> wrote:

> Thanks for your helpful reply. Hopefully I can figure out how to call that
> $table->getDefaultMetadataCache()->clean() at the right time / in the
> right context.
>
> -JB
>
>
> ------------------------------
> *From:* Саша Стаменковић <[hidden email]>
>
> *To:* JBChristy <[hidden email]>
> *Cc:* [hidden email]
> *Sent:* Mon, March 7, 2011 10:57:20 PM
>
> *Subject:* Re: [fw-db] Programmatically Clear Metadata Cache?
>
> You can set table metadata cache with
>
> $cache = Zend_Cache::factory(...);
> Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
>
> and clear cache with
>
> $cache->clean(...);
>
> when the metadata changes.
>
> ---
> Regards,
> Saša Stamenković
>
>
> On Mon, Mar 7, 2011 at 10:40 PM, JBChristy <[hidden email]> wrote:
>
>> I've just up automatic (mem)caching of all Zend_DB_Table's. From time to
>> time, of course, the metadata changes. We do this in our production
>> environment by running sql scripts that add / drop / change columns as
>> necessary. I need some programmatic way to expire the metadata cache after
>> the sql runs, and no later than when updated code goes live, which is a
>> matter of minutes. I can't just wait til it times out.
>>
>> I've dug into Zend 1.11 Zend_Db_Table_Abstract, and the memcache key is an
>> md5 encoding of an optional port, optional host, dbname, schema name and
>> table name. There does not appear to be member function to expire the
>> cache,
>> nor even a function to return the md5 encoded key so I can delete it
>> manually.
>>
>> How are we supposed to clear the metadata cache when the metadata changes?
>>
>> Thanks in advance for your help!
>>
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/Programmatically-Clear-Metadata-Cache-tp3340068p3340068.html
>> Sent from the Zend DB mailing list archive at Nabble.com.
>>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Programmatically Clear Metadata Cache?

localheinz
> You can save cache to registry or get it from bootstrap as it is the same
> instance as in table if that comes handy for you.

Also consider using Zend_Cache_Manager as a resource bootstrappable via application.ini, as you can retrieve the cache from there, too (especially if you have more than one cache instance).


Says: Andreas.
Loading...