Memcached PHP Sessions

Jure Petrovic fonz at siol.net
Fri Feb 2 17:19:09 UTC 2007


Maybe you can implement a wrapper that would give you
the abstraction of an array.
You call set() on array, but the wrapper saves it as multiple
objects just as Reinis proposed. Then you can get an index
of an array, because it's simply denoted by a key. And if you
want to get whole array, you simply do a multi-key-get.

I guess this would work for me too. But, still, don't you think
that in C you could somehow get an index of an array by simply
adding an offset?

For example, if my array of  int's is 16 bytes and I want the
second one I could get(key, offset) or get(key, offset, sizeof(my_struct)) 
for
arbitrary objects.

Do you think that such adition to memcached would be feasible?

Regards,
Jure Petrovic

----- Original Message ----- 
From: "Reinis Rozitis" <roze at roze.lv>
To: "Jure Petrovic" <fonz at siol.net>; "Roberto Spadim" 
<roberto at spadim.com.br>
Cc: <memcached at lists.danga.com>
Sent: Friday, February 02, 2007 5:45 PM
Subject: Re: Memcached PHP Sessions


>> since i need only change array index 0 on first and index 1 on second i
>> shouldn't change all array because i will get the last changed, could we
>> implement some features ONLY for ARRAY (or coletions (associative
>> with it we could get array back with
>> ->fetch('variable')
>> or better:
>> ->fetch('variable[index that i want]');
>
> There is no way that MemCached could do it at least at the current state
> (and In my opinion there is also no need).
> Cause Memcached does NOT have any idea about PHPs data structure or any
> programming language's.
> In case of php the data stored is as serialised string and if you want to
> fetch only part Memcached would have to operate with some substrings and 
> on
> update try to squeeze back in and rewrite the whole syntax (like 
> length/type
> and so on).
>
> If you want to partly fetch/update use different keys for each array
> element:
> For example $variable[0] = 'value'; becomes set('variable_0','value') ..
>
>> I still have to transfer whole array to get one index. If I want to 
>> change
> something, whole array has to be transfered again.
>
> This indicates you are using MemCached the wrong way and your data should 
> be
> packed (splited) in a different manner (see above). 



More information about the memcached mailing list