Append + Search Commands

View: New views
2 Messages — Rating Filter:   Alert me  

Append + Search Commands

by Filipe Laborde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, this is my first post to this list so let me introduce myself.

We are a Canadian company that uses memcache for our website (www.desi-planet.com), and have found the program very useful -- it cut a heavy database load down by over 95%.

There was a patch for the append and prefix-flush commands back with version 1.1.1, but those versions are gone and this new version did not have these functions which I needed. Thus here's a patch to offer these additions:

Commands:
SEARCH {prefix word}
APPEND {key} {flags} {expiry} {size}

The search will find all the keys in the memcached server that match the prefix. However, some of the returned results will already have expired, so it's mainly useful when you will do a delete of those entries or a get of them. I use it to delete all message posts with certain prefixes.

The append works like a REPLACE but keeps the previous data and appends the new data.

More meta-data with GET command:
I have included the time-to-expiry information in the GET returns (its the first numbe after the key):
> get bh
VALUE bh 270 10 20
0123456789ABCDABCD..
END

I use this information for deciding how soon I need to update database caches. If I wait till the item has expired, it can cause a massive spike in my database as all users wait for the database to get the info. If I know it's goign to expire, I can gracefully update it 10-15 seconds before it does with new data, and it won't affect users.




memcached_append_search.patch (7K) Download Attachment

Re: Append + Search Commands

by Song Du :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I guess the SEARCH command might be inefficient here.

On 5/18/07, Filipe Laborde <fil@...> wrote:

> Hello, this is my first post to this list so let me introduce myself.
>
> We are a Canadian company that uses memcache for our website
> (www.desi-planet.com), and have found the program very useful -- it cut a
> heavy database load down by over 95%.
>
> There was a patch for the append and prefix-flush commands back with version
> 1.1.1, but those versions are gone and this new version did not have these
> functions which I needed. Thus here's a patch to offer these additions:
>
> Commands:
> SEARCH {prefix word}
> APPEND {key} {flags} {expiry} {size}
>
> The search will find all the keys in the memcached server that match the
> prefix. However, some of the returned results will already have expired, so
> it's mainly useful when you will do a delete of those entries or a get of
> them. I use it to delete all message posts with certain prefixes.
>
> The append works like a REPLACE but keeps the previous data and appends the
> new data.
>
> More meta-data with GET command:
> I have included the time-to-expiry information in the GET returns (its the
> first numbe after the key):
> > get bh
> VALUE bh 270 10 20
> 0123456789ABCDABCD..
> END
>
> I use this information for deciding how soon I need to update database
> caches. If I wait till the item has expired, it can cause a massive spike in
> my database as all users wait for the database to get the info. If I know
> it's goign to expire, I can gracefully update it 10-15 seconds before it
> does with new data, and it won't affect users.
>
>
>
>