|
Re: memcache(3) 1.2.0 released...: msg#00022web.cache.memcached
On Wed, 2005-01-12 at 21:46 +0300, Antony Dovgal wrote: > On Wed, 12 Jan 2005 10:35:54 -0800 > John McCaskey <johnm@xxxxxxxx> wrote: > > > The one major complaint I have with the current php oo api's (and > > possibly the Ruby api) are that they simply return FALSE (nil for > > Ruby?) for an unfound key, thus breaking the ability to store > > arbitrary binary data as I now cannot store a FALSE, or a binary > > equivalent in memcache. > > Why? > Just don't store anything and you'll get the same result - FALSE. That doesn't help though. What if I have a database or other slow storage where I'm getting boolean values out in a large quantity and both TRUE and FALSE are valid values that I need to retrieve and use. If I get a cache miss it indicates to me that I need to hit this storage to find out whether the value is TRUE or FALSE. However, if I get a FALSE out then I don't need to hit the storage I should just use the FALSE as my value. If the get() command however returns a FALSE for either my stored FALSE value or for a miss, then I will always have to assume its a miss and hit the slow storage everytime I retrieve a FALSE. Am I missing something here? I can't see it if so. > > Or store FALSE and get empty string as get() value (it seems quite > logical to me that "" == FALSE just because they _are_ equal). > > I don't see any problems here, but I appreciate any > help/suggestions/improvements. > > > Perhaps, I'll always return as an array('key'=>'value', ..., > > 'keyn'=>'valuen') and the way to determine a miss is simply that the > > key does not exist at all, and then NULL or FALSE are valid data from > > the cache. > > You've missed something =) > > <?php > $m = memcache_connect("localhost"); > $m->set("var", FALSE); > $m->get(Array("var", "nonexistent_key")); > ?> > ---- > bool(true) > array(1) { > ["var"]=> > string(0) "" > } Thats great, but it's also exactly what I explained as my plan right? This does definately improve the usuability of your PECL client for me though. > ---- > > But thanks, I just realized that I forgot to add this syntax to the docs. > > > If I did this as a php5 module, maybe I'd just throw an exception... > > but alas I need to use php4. > > Throwing an exception when there is no such key seems a bit scary to me. > I used to think that exceptions are throwed in case of some errors, but > missing key doesn't look as error to me. > I agree with that, it was just a quick thought. But you are very right, it would probably be a bit of an abuse of exceptions. -- John A. McCaskey Software Development Engineer Klir Technologies, Inc. johnm@xxxxxxxx 206.902.2027 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: memcache(3) 1.2.0 released...: 00022, Antony Dovgal |
|---|---|
| Next by Date: | Re: memcache(3) 1.2.0 released...: 00022, Sean Chittenden |
| Previous by Thread: | Re: memcache(3) 1.2.0 released...i: 00022, Antony Dovgal |
| Next by Thread: | Re: memcache(3) 1.2.0 released...: 00022, Antony Dovgal |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |