Re: Implementation of CHECK command for memcached
hum, a check sometimes is nice for small network use... thinking about apc (php) cache, it don´t have a check, but it use only local memory cache maybe network could have this 'feature', just to optimize some codes, not related to cache, but to network protocol/network otimization 2011/3/18 Dustin : > > On Mar 18, 3:28 pm, Roberto Spadim wrote: >> for example, if a key of cache is >> key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ >> if we check key_1 and it return not exists, we don´t need to check >> key_1_1,2,3,4 > > Why wouldn't you just do them all at once? That'll be fewer round > trips assuming low miss rates. Why would you want to trade low > latency for inaccuracy? maybe with a noSQL it´s usefull (memcachedb, membase) > >> it´s a feature, some cache problems could get improvement with it. >> i think it´s very good =) >> think about http sessions >> just check if a variable exists in cache (it can be very big) >> if not exists get from session database (invalidade all cache values >> (delete)) >> if exists get all cache values from cache > > How about this: > > Request it. > If it exists, use it. > If it doesn't exist, go back to the DB. > > -- Roberto Spadim Spadim Technology / SPAEmpresarial
Re: Implementation of CHECK command for memcached
On Mar 18, 3:28 pm, Roberto Spadim wrote: > for example, if a key of cache is > key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ > if we check key_1 and it return not exists, we don´t need to check > key_1_1,2,3,4 Why wouldn't you just do them all at once? That'll be fewer round trips assuming low miss rates. Why would you want to trade low latency for inaccuracy? > it´s a feature, some cache problems could get improvement with it. > i think it´s very good =) > think about http sessions > just check if a variable exists in cache (it can be very big) > if not exists get from session database (invalidade all cache values (delete)) > if exists get all cache values from cache How about this: Request it. If it exists, use it. If it doesn't exist, go back to the DB.
Re: Implementation of CHECK command for memcached
yeah it´s just a idea, cache values not get will get from session db for example the point here is a scenario with cache server with loaded (network or low memory) it sound nice to tweak some code with this 'check' feature. i don´t know if will have a performace boost, just testing... 2011/3/18 Les Mikesell : > On 3/18/2011 5:28 PM, Roberto Spadim wrote: >> >> hummm i think it´s a cache feature... >> for example, if a key of cache is >> key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ >> if we check key_1 and it return not exists, we don´t need to check >> key_1_1,2,3,4 >> it´s a feature, some cache problems could get improvement with it. >> i think it´s very good =) >> think about http sessions >> just check if a variable exists in cache (it can be very big) >> if not exists get from session database (invalidade all cache values >> (delete)) > > What if the reason it doesn't exist is that it just got evicted - but some > or all of your related keys might still be there? Or maybe the server > holding that key just went down. > >> if exists get all cache values from cache > > Likewise they may be evicted/expired separately. > > -- > Les Mikesell > lesmikes...@gmail.com > > -- Roberto Spadim Spadim Technology / SPAEmpresarial
Re: Implementation of CHECK command for memcached
On 3/18/2011 5:28 PM, Roberto Spadim wrote: hummm i think it´s a cache feature... for example, if a key of cache is key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ if we check key_1 and it return not exists, we don´t need to check key_1_1,2,3,4 it´s a feature, some cache problems could get improvement with it. i think it´s very good =) think about http sessions just check if a variable exists in cache (it can be very big) if not exists get from session database (invalidade all cache values (delete)) What if the reason it doesn't exist is that it just got evicted - but some or all of your related keys might still be there? Or maybe the server holding that key just went down. if exists get all cache values from cache Likewise they may be evicted/expired separately. -- Les Mikesell lesmikes...@gmail.com
Re: Implementation of CHECK command for memcached
there´s a problem (i think) that some noSQL database use memcache protocol, and they want to libmemcache be in sync with these features maybe we should change some things memcached (repcache) cache daemon libmemcache (tcp/udp protocol) nosql daemon (memcachedb, membase, others..) just a idea... libmemcache - protocol (this type of feature request) memcached - daemon (cache values/nosql database values) 2011/3/18 Roberto Spadim : > hummm i think it´s a cache feature... > for example, if a key of cache is > key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ > if we check key_1 and it return not exists, we don´t need to check > key_1_1,2,3,4 > it´s a feature, some cache problems could get improvement with it. > i think it´s very good =) > think about http sessions > just check if a variable exists in cache (it can be very big) > if not exists get from session database (invalidade all cache values (delete)) > if exists get all cache values from cache > don´t need to make a lot of network i/o on low memory cache servers, > just a single ping-pong (check command) with some 200bytes? total > packet. > > it´s a feature request. not a problem/bug. i think it´s nice =) > > 2011/3/18 Les Mikesell : >> On 3/18/2011 4:03 PM, Roberto Spadim wrote: >>> >>> check have a low network traffic, i think it´s a nice command >> >> Yes, and I don't see why it would be a problem to implement. I just don't >> see the point when by the time you get the answer it might not be true, and >> if you try to apply an new expire with it the underlying value for the key >> might have already been changed or removed. It just doesn't seem to mesh >> with the operations that work in a cache. >> >> -- >> Les Mikesell >> lesmikes...@gmail.com >> >> > > > > -- > Roberto Spadim > Spadim Technology / SPAEmpresarial > -- Roberto Spadim Spadim Technology / SPAEmpresarial
Re: Implementation of CHECK command for memcached
hummm i think it´s a cache feature... for example, if a key of cache is key_1 , key_1_1, hey_1_2 , key_1_3, key_1_ if we check key_1 and it return not exists, we don´t need to check key_1_1,2,3,4 it´s a feature, some cache problems could get improvement with it. i think it´s very good =) think about http sessions just check if a variable exists in cache (it can be very big) if not exists get from session database (invalidade all cache values (delete)) if exists get all cache values from cache don´t need to make a lot of network i/o on low memory cache servers, just a single ping-pong (check command) with some 200bytes? total packet. it´s a feature request. not a problem/bug. i think it´s nice =) 2011/3/18 Les Mikesell : > On 3/18/2011 4:03 PM, Roberto Spadim wrote: >> >> check have a low network traffic, i think it´s a nice command > > Yes, and I don't see why it would be a problem to implement. I just don't > see the point when by the time you get the answer it might not be true, and > if you try to apply an new expire with it the underlying value for the key > might have already been changed or removed. It just doesn't seem to mesh > with the operations that work in a cache. > > -- > Les Mikesell > lesmikes...@gmail.com > > -- Roberto Spadim Spadim Technology / SPAEmpresarial
Re: Implementation of CHECK command for memcached
On 18. mars 2011, at 13.41, Adam Lee wrote: > Is it also your intention to have CHECK with an expiration act as a sort of > touch command? > I pushed a binary TOUCH command a while back for the upcoming engine branch (in addition to a "get and touch"). The touch command is used to update the expiry time of the object (and not return the value). Both returns "not found" if the keys's not there... Trond > On Fri, Mar 18, 2011 at 1:12 PM, Oleg Romanenko > wrote: > Hi. > > >How could this be put to use? i.e. when is knowing that > > something exists at some point in an ephemeral store useful to an > > application? > > This command provides support for lazy read operation. You can read > the value of the key only when is really necessary. > For example: > 1. I am storing some information about the client in memcached. The > key - is the name of the session, which is is given to the client. > 2. I have a lot of service scripts that should check the rights of > clients. They need only to know whether there is a key (then > everything is OK) or not (then the client is redirected to the login > script). > 3. And I have only two scripts that use the value of a key in they > work. > > Of course, this problem can be solved by creating an additional (flag) > key(s) without content. But such approach is less secure and in > generally reduces the consistency of system's data (for example, key > with data can be deleted when the flag key still remain available). > > > > -- > awl
Re: Implementation of CHECK command for memcached
On 3/18/2011 4:03 PM, Roberto Spadim wrote: check have a low network traffic, i think it´s a nice command Yes, and I don't see why it would be a problem to implement. I just don't see the point when by the time you get the answer it might not be true, and if you try to apply an new expire with it the underlying value for the key might have already been changed or removed. It just doesn't seem to mesh with the operations that work in a cache. -- Les Mikesell lesmikes...@gmail.com
Re: Implementation of CHECK command for memcached
check have a low network traffic, i think it´s a nice command 2011/3/18 Les Mikesell : > On 3/18/2011 3:12 PM, Oleg Romanenko wrote: >> >> Hi. >> >>> How could this be put to use? i.e. when is knowing that >>> something exists at some point in an ephemeral store useful to an >>> application? >> >> This command provides support for lazy read operation. You can read >> the value of the key only when is really necessary. >> For example: >> 1. I am storing some information about the client in memcached. The >> key - is the name of the session, which is is given to the client. >> 2. I have a lot of service scripts that should check the rights of >> clients. They need only to know whether there is a key (then >> everything is OK) or not (then the client is redirected to the login >> script). >> 3. And I have only two scripts that use the value of a key in they >> work. >> >> Of course, this problem can be solved by creating an additional (flag) >> key(s) without content. But such approach is less secure and in >> generally reduces the consistency of system's data (for example, key >> with data can be deleted when the flag key still remain available). > > Seems odd to not care about the content in a cache where you aren't > guaranteed any relationship from one access to the next. That is, don't you > have situations here where a check would say a key exists but when you try > to retrieve it, it doesn't (expired, evicted, deleted by a concurrent > operation, etc.)? > > -- > Les Mikesell > lesmikes...@gmail.com > > -- Roberto Spadim Spadim Technology / SPAEmpresarial
Re: Implementation of CHECK command for memcached
On 3/18/2011 3:12 PM, Oleg Romanenko wrote: Hi. How could this be put to use? i.e. when is knowing that something exists at some point in an ephemeral store useful to an application? This command provides support for lazy read operation. You can read the value of the key only when is really necessary. For example: 1. I am storing some information about the client in memcached. The key - is the name of the session, which is is given to the client. 2. I have a lot of service scripts that should check the rights of clients. They need only to know whether there is a key (then everything is OK) or not (then the client is redirected to the login script). 3. And I have only two scripts that use the value of a key in they work. Of course, this problem can be solved by creating an additional (flag) key(s) without content. But such approach is less secure and in generally reduces the consistency of system's data (for example, key with data can be deleted when the flag key still remain available). Seems odd to not care about the content in a cache where you aren't guaranteed any relationship from one access to the next. That is, don't you have situations here where a check would say a key exists but when you try to retrieve it, it doesn't (expired, evicted, deleted by a concurrent operation, etc.)? -- Les Mikesell lesmikes...@gmail.com
Re: Implementation of CHECK command for memcached
On Fri, Mar 18, 2011 at 1:12 PM, Oleg Romanenko wrote: > Hi. > >>How could this be put to use? i.e. when is knowing that >> something exists at some point in an ephemeral store useful to an >> application? > > This command provides support for lazy read operation. You can read > the value of the key only when is really necessary. > For example: > 1. I am storing some information about the client in memcached. The > key - is the name of the session, which is is given to the client. > 2. I have a lot of service scripts that should check the rights of > clients. They need only to know whether there is a key (then > everything is OK) or not (then the client is redirected to the login > script). > 3. And I have only two scripts that use the value of a key in they > work. > > Of course, this problem can be solved by creating an additional (flag) > key(s) without content. But such approach is less secure and in > generally reduces the consistency of system's data (for example, key > with data can be deleted when the flag key still remain available). I don't know what client language you use, but PHP's memcache::get( ) method says: "Returns the string associated with the key or FALSE on failure or if such key was not found. " So in my app I can do something like if( $value = $mc->get( $key ) ); { // yep }else{ //nope } 1 trip to the server. The check is built into get command, because I didn't get the value I wanted.
Re: Implementation of CHECK command for memcached
Is it also your intention to have CHECK with an expiration act as a sort of touch command? On Fri, Mar 18, 2011 at 1:12 PM, Oleg Romanenko wrote: > Hi. > > >How could this be put to use? i.e. when is knowing that > > something exists at some point in an ephemeral store useful to an > > application? > > This command provides support for lazy read operation. You can read > the value of the key only when is really necessary. > For example: > 1. I am storing some information about the client in memcached. The > key - is the name of the session, which is is given to the client. > 2. I have a lot of service scripts that should check the rights of > clients. They need only to know whether there is a key (then > everything is OK) or not (then the client is redirected to the login > script). > 3. And I have only two scripts that use the value of a key in they > work. > > Of course, this problem can be solved by creating an additional (flag) > key(s) without content. But such approach is less secure and in > generally reduces the consistency of system's data (for example, key > with data can be deleted when the flag key still remain available). > -- awl
Re: Implementation of CHECK command for memcached
Hi. >How could this be put to use? i.e. when is knowing that > something exists at some point in an ephemeral store useful to an > application? This command provides support for lazy read operation. You can read the value of the key only when is really necessary. For example: 1. I am storing some information about the client in memcached. The key - is the name of the session, which is is given to the client. 2. I have a lot of service scripts that should check the rights of clients. They need only to know whether there is a key (then everything is OK) or not (then the client is redirected to the login script). 3. And I have only two scripts that use the value of a key in they work. Of course, this problem can be solved by creating an additional (flag) key(s) without content. But such approach is less secure and in generally reduces the consistency of system's data (for example, key with data can be deleted when the flag key still remain available).
Re: Implementation of CHECK command for memcached
On Mar 15, 9:28 am, Oleg Romanenko wrote: > Hello. > I've been using memcached for storing data with a short lifetime and I > found that the use of the "add" command to test the existence of a key > requires additional expenses, because if the key does not exist > already (expired) - it will be recreated. > I have implemented a new command "check", which allows you to verify > the existence of a key. This command also allows you to set a new > expiration time for a key. Hey, saw your change. It looks pretty thorough. :) We've done some similar work in the engine branch for setting expiration. I don't think it makes sense to check for the existence of a key, however. How could this be put to use? i.e. when is knowing that something exists at some point in an ephemeral store useful to an application?