On Feb 23, 2:29 am, fapre wrote:
> Ok, here is a short example.
>
> There are two Threads -> ThreadA and ThreadB (TA, TB)
> Both want to read, change and write a object called Object1
>
> So, if both thread read the object there will be no problem.
>
> But if both change the values of the Object
On Feb 23, 6:51 pm, Toru Maesaka wrote:
> But in the actual implementation, we're using a period/dot as the
> separator :)
>
> This isn't such a big deal but I'd like to fix it in the 1.3 binary tree. The
> question is, which is correct? I would suspect that the correct thing in
> this case is
G'day
There's an inconsistency between the ascii protocol documentation and
the actual server implementation regarding stats. Specifically, I'm talking
about rusage_user and rusage_system entries.
So, in docs/protocol.txt it is stated that:
" '32u:32u' means two 32-but unsigned integers separat
On Feb 23, 7:09 am, "wsny...@wsnyder.org" wrote:
> What I would really like is a cas_multi that says "insert if doesn't
> exist"
> rather than this more complicated loop that requires me to split the
> gets_multi results into two separate arrays (those to modify and
> those to add.)
>
> Is ther
this looks like a pretty efficient summary of the whole thread !
To come back on Dormando's point: any global consistency issue can be solved
by full flush, so I can't honestly say it is an absolutely necessary
feature. However, by dramatically reducing the DB cost of such flush
operations, (you
On Feb 22, 5:02 pm, dormando wrote:
> It feels excessive if the only real benefit is being able to do a full
> data flush in less time? Is there anything I'm missing?
This is kind of how I see it:
Pros:
* It's consistent with flush_all [n] for positive values of n if you
consider flush_al
I would recommend that the check of variable $value is done by === instead
if (false === $value)
{
// it didn't exist
}
=== is true if the types on left side and right side are the same, and if
the values are the same. It's a good habit to do.
if (false === strpos("are you here", "are"))
{
thanks for your insight on memcache implementation.. I have change the code
according to Colin Pitrat example..
Mine was just a basic memcache utilization, put it along while coding for a
small website.
Thanks a lot.
On Mon, Feb 23, 2009 at 10:29 PM, Colin Pitrat wrote:
> Yes, you should clearly
Yes, you can avoid this problem with the CAS (Check And Set) feature of
memcached. Basically, when you do a get you can get a cas-id back as well,
and if you supply that id back when you're setting the object again, it will
fail if the id's don't match, and the id changes every time the stored item
In the main project where I'm using memcached there's basically three
distinct cases of caching DB results:
The first is objects that are very common, for example users. These we cache
individually, and if we need to cache a list of users, we cache a list of
user-ids, and whenever we need a specif
Sorry, submitted early!
The two ways I see to deal with this are to see what keys fail
the CAS update and retry those, or the more complicated loop:
while (...) {
gets_multi # returns CAS and also what keys don't exist
if (key doesn't exist) {
add_multi
repeat loop with
I have an application where I'm doing atomic accesses on the data.
For simplicity assume I'm just incrementing a number (it's not, so I
can't use the builtin.) I'm using the Perl Cache::Memcached::Fast
interface.
Keys may exist or may not. The problem is I don't see a way to both
update existin
Yes, you should clearly adapt your code:
$key = 'prodpics_'.$id;
$value=$mmc->get($key);
// Handle cache miss
if($value == '')
{
$value = get_from_db();
$mmc->set($key,$value, false, 3600);
}
echo $value;
I also removed the _variable suffix, because we now it's a variable ;-)
2009/2/23
You don't actually want to check for the nullness of the key first. In
caching, you want to get the data, check for nullness on the get, and then
set the cache if the get is empty. If you do it your way, you have the
potential for double access (which you are seeing), or alternatively, the
get of
Ok, here is a short example.
There are two Threads -> ThreadA and ThreadB (TA, TB)
Both want to read, change and write a object called Object1
So, if both thread read the object there will be no problem.
But if both change the values of the Object1 and ThreadA writes it
back before ThreadB writ
Thanks for your reply..
Ya, that double cmd_get is on the 2nd run.. Isnt it becoz it check the key
whether empty or not, and for sure its not empty, then another get. So, 2
cmd_get for each function call
$key_variable = 'prodpics_'.$id;
if($mmc->get($key_variable) == ''){
//query from database
$m
Of course, this is normal ! The first time, the cache is empty, so each
query fail, and fill in the cache with corresponding data. On second time,
the cache is full, so everything is found in the cache. The only strange
thing is that you get exactly two times more query on the second one than on
th
Not totally stopped, but are able to lose one or two instances and
continue to function. That's a defined requirement for all subsystems of
an operation. Redundant DB's so you can lose one, several gearmand's so
you can lose one, enough memcached's so losing one or two is fine, etc.
Anything else
You mean something like "In n seconds, remove all items that have not been
updated until then" ? That's the way I first thought flush with ttl would
work, and I was quite disappointed when I understood that it wasn't the
case. When you give it a thought, that's the same thing as waiting n seconds
a
19 matches
Mail list logo