Send memcached mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.danga.com/mailman/listinfo/memcached
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of memcached digest..."
Today's Topics:
1. telling code to pull from the database when the data in a
table changes (Nathan Nobbe)
2. Re: telling code to pull from the database when the data in a
table changes (Tomas Markauskas)
3. Re: telling code to pull from the database when the data in a
table changes (Thomas Seifert)
4. Re: telling code to pull from the database when the data in a
table changes (KevinImNotSpacey)
----------------------------------------------------------------------
Message: 1
Date: Mon, 21 May 2007 10:05:19 -0400
From: "Nathan Nobbe" <[EMAIL PROTECTED]>
Subject: telling code to pull from the database when the data in a
table changes
To: [email protected]
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
All,
I recently began investigating memcached, and im very excited about
it. im
planning on using it w/ php to implement variables whose lifetime can be
the
duration of the application.
I understand that storing the results of queries to the database can
increase efficiency if those variables are checked for the data first on
consecutive requests for the data they store, but
i still have a disconnect...
what i dont understand is when the data profile of a particular table
changes, and the variable in the memcache that represents that table
becomes
stale, how can the variable be updated efficiently?
obviously w/ php and a unix system, a simple cron could be used to poll
the
database periodically to see if there are changes to the data profile of a
given table. i was thinking to make this even more
efficient; triggers could be employed (im using mysql 5+) to update a
table,
call it recent_tables_that_changed, dedicated to signifying particular
tables in the database have changed. then the cron'd php script could
simply check recent_tables_that_changed to determine which, if any,
application variables had become stale (do to a change in data profile).
the stale variable could then be updated and the record removed from
recent_tables_that_changed.
though decent, i am personally not a fan of this approach, because there
would still be a frequent query running against the database just to
determine what data had changed so that application variables in the cache
would not remain stale for long once theyve become stale. additionally,
the
mechanisms' responsiveness would be limited to the time granularity of
cron,
which i believe is a minute. im wondering if there is some way to signal
the cache only when tables, represented by application variables, have
changed. if you dont feel like typing out a response, because this is
probably a naive question, would anyone mind directing me to a resource or
two where i could read up on the topic myself?
(sorry for the lengthy posting)
thanks,
-Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.danga.com/pipermail/memcached/attachments/20070521/ac143a94/attachment-0001.htm
------------------------------
Message: 2
Date: Mon, 21 May 2007 16:12:17 +0200
From: "Tomas Markauskas" <[EMAIL PROTECTED]>
Subject: Re: telling code to pull from the database when the data in a
table changes
To: "Nathan Nobbe" <[EMAIL PROTECTED]>, [email protected]
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Hello,
why not deleting/updating the cache entry when you updating the table?
At that moment you know, which rows you're updating.
Tomas
On 5/21/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> All,
>
> I recently began investigating memcached, and im very excited about
it. im
> planning on using it w/ php to implement variables whose lifetime can be
the
> duration of the application.
> I understand that storing the results of queries to the database can
> increase efficiency if those variables are checked for the data first on
> consecutive requests for the data they store, but
> i still have a disconnect...
> what i dont understand is when the data profile of a particular table
> changes, and the variable in the memcache that represents that table
becomes
> stale, how can the variable be updated efficiently?
> obviously w/ php and a unix system, a simple cron could be used to poll
the
> database periodically to see if there are changes to the data profile of
a
> given table. i was thinking to make this even more
> efficient; triggers could be employed (im using mysql 5+) to update a
table,
> call it recent_tables_that_changed, dedicated to signifying particular
> tables in the database have changed. then the cron'd php script could
> simply check recent_tables_that_changed to determine which, if any,
> application variables had become stale (do to a change in data profile).
> the stale variable could then be updated and the record removed from
> recent_tables_that_changed.
> though decent, i am personally not a fan of this approach, because there
> would still be a frequent query running against the database just to
> determine what data had changed so that application variables in the
cache
> would not remain stale for long once theyve become stale. additionally,
the
> mechanisms' responsiveness would be limited to the time granularity of
cron,
> which i believe is a minute. im wondering if there is some way to
signal
> the cache only when tables, represented by application variables, have
> changed. if you dont feel like typing out a response, because this is
> probably a naive question, would anyone mind directing me to a resource
or
> two where i could read up on the topic myself?
>
> (sorry for the lengthy posting)
> thanks,
>
> -Nathan
>
------------------------------
Message: 3
Date: Mon, 21 May 2007 16:14:30 +0200
From: Thomas Seifert <[EMAIL PROTECTED]>
Subject: Re: telling code to pull from the database when the data in a
table changes
To: Nathan Nobbe <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
Hi Nathan,
I think thats simply up to the application how this is handled.
E.g. you could just "delete" or "update" the cached variable at the
place where the data in the table is changed, thats
how we handle it in most areas.
Or you use some "version" which increases if the data changed and use
that version-number together with the key to retrieve
data from memcached.
thomas
Nathan Nobbe schrieb:
> All,
>
> I recently began investigating memcached, and im very excited about
> it. im planning on using it w/ php to implement variables whose
> lifetime can be the duration of the application.
> I understand that storing the results of queries to the database can
> increase efficiency if those variables are checked for the data first
> on consecutive requests for the data they store, but
> i still have a disconnect...
> what i dont understand is when the data profile of a particular table
> changes, and the variable in the memcache that represents that table
> becomes stale, how can the variable be updated efficiently?
> obviously w/ php and a unix system, a simple cron could be used to
> poll the database periodically to see if there are changes to the data
> profile of a given table. i was thinking to make this even more
> efficient; triggers could be employed (im using mysql 5+) to update a
> table, call it recent_tables_that_changed, dedicated to signifying
> particular tables in the database have changed. then the cron'd php
> script could simply check recent_tables_that_changed to determine
> which, if any, application variables had become stale (do to a change
> in data profile). the stale variable could then be updated and the
> record removed from recent_tables_that_changed.
> though decent, i am personally not a fan of this approach, because
> there would still be a frequent query running against the database
> just to determine what data had changed so that application variables
> in the cache
> would not remain stale for long once theyve become stale.
> additionally, the mechanisms' responsiveness would be limited to the
> time granularity of cron, which i believe is a minute. im wondering
> if there is some way to signal the cache only when tables, represented
> by application variables, have changed. if you dont feel like typing
> out a response, because this is probably a naive question, would
> anyone mind directing me to a resource or two where i could read up on
> the topic myself?
>
> (sorry for the lengthy posting)
> thanks,
>
> -Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.danga.com/pipermail/memcached/attachments/20070521/bcf60a26/attachment-0001.html
------------------------------
Message: 4
Date: Mon, 21 May 2007 09:17:16 -0500
From: KevinImNotSpacey <[EMAIL PROTECTED]>
Subject: Re: telling code to pull from the database when the data in a
table changes
To: "Nathan Nobbe" <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
Hey Nathan,
I think the appropriate solution is largely dependent on your particular
situation. For instance, we have one website that is media hosting, we
cache media requests for 10 minutes. Now if a user updates their media
description or something we simply tell them that it will not show up on
the
site right away. Then after roughly ten minutes the media expires from
cache, upon the next request our php code gets null back from memcached,
gets the media from the database and disk, puts in memcache and then
returns.
So we don't use cron or any other batch processing, instead we figure that
stale for 10 minutes is ok and just let the content naturally expire from
cache.
Hope this helps,
Kevin
On 5/21/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> All,
>
> I recently began investigating memcached, and im very excited about it.
> im planning on using it w/ php to implement variables whose lifetime can
be
> the duration of the application.
> I understand that storing the results of queries to the database can
> increase efficiency if those variables are checked for the data first on
> consecutive requests for the data they store, but
> i still have a disconnect...
> what i dont understand is when the data profile of a particular table
> changes, and the variable in the memcache that represents that table
becomes
> stale, how can the variable be updated efficiently?
> obviously w/ php and a unix system, a simple cron could be used to poll
> the database periodically to see if there are changes to the data
profile of
> a given table. i was thinking to make this even more
> efficient; triggers could be employed (im using mysql 5+) to update a
> table, call it recent_tables_that_changed, dedicated to signifying
> particular tables in the database have changed. then the cron'd php
script
> could simply check recent_tables_that_changed to determine which, if
any,
> application variables had become stale (do to a change in data profile).
> the stale variable could then be updated and the record removed from
> recent_tables_that_changed.
> though decent, i am personally not a fan of this approach, because there
> would still be a frequent query running against the database just to
> determine what data had changed so that application variables in the
cache
> would not remain stale for long once theyve become stale. additionally,
> the mechanisms' responsiveness would be limited to the time granularity
of
> cron, which i believe is a minute. im wondering if there is some way to
> signal the cache only when tables, represented by application variables,
> have changed. if you dont feel like typing out a response, because this
is
> probably a naive question, would anyone mind directing me to a resource
or
> two where i could read up on the topic myself?
>
> (sorry for the lengthy posting)
> thanks,
>
> -Nathan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.danga.com/pipermail/memcached/attachments/20070521/32de3ddf/attachment.htm
------------------------------
_______________________________________________
memcached mailing list
[email protected]
http://lists.danga.com/mailman/listinfo/memcached
End of memcached Digest, Vol 34, Issue 42
*****************************************