php-memcache, delete, expiration questions, ideas

mike mike503 at gmail.com
Mon Dec 5 09:25:08 UTC 2005


http://www.klir.com/~johnm/php-mcache/

might help with some of your concerns... looks like a better memcached
extension.

On 12/5/05, Veres Lajos <vlajos at ludens.elte.hu> wrote:
> Hello,
>
> I'm a new user of memcache, and I'm very pleased with his performance.
>
> We are using memcache for 2 reasons:
> 1. store users session information in all cache server
> 2. store cached data distributed between cache servers
>
> We are using the php pecl api with a small wrapper for able to connect
> more servers at the same time, and with some function for
> store/delete/fetch data from/to all servers.
>
> I tested the difference between storing data in all server or only one
> server, and the penalty wasnt too painfull with persistence connections:
> 592 request/sec vs 555 request/sec (with 2 servers.)
> get_fromall command are working by trying first localhost.
>
> I think this set_toall,get_fromall,delete_fromall operations may helpfull
> for any distributed APIS.
> At least for "session" or other "original-in-memcache" like data.
>
> We are storing the 2 type of data as i wrote, but I dont understand really
> the expiration policy of memcache.
> I should ensure our session data wont be dropped before his expiration
> time, but as I seen if cache is nearly filled there is some chance
> for this.
> Exists any detailed description how expiration works?
>
> For able to choose enought memory for memcached to avoid dropping
> sessions, i started to log "bytes" provided by memcache_getstats
> (php.net/memcache-getstats)
> But it seems to growing continuosly.
> This is very strange because all data we are storing has expiration.
> Or expiration only happens if cache nearly filled?
>
> As I seen in the mailing lists, the php-pecl APIs only disadvantage it
> cant store "server-down" information with a "correct" way.
> I guess this could be done with a "connection description" file or
> something like this:
>
> -if(read "servers.cache.cfg"){
> -       $servers loaded
> -}else{ read "servers.cfg"){
> -       $servers loaded
> -}
> -try to connect to all servers
> -if any fails then regenerate servers.cache.cfg without failed servers
> -if all OK and servers.cache isnt existed then save servers.cache.cfg
>
> And here needs some expirations method for servers.cache.cfg.
> I guess we could get a random number from for example time, and/or client
> ip, and/or apache unique_id or any better random like thing.
> And if this random number matches a configurable chance (1% or similar),
> than we can check mtime of servers.cache.cfg, and delete if older than some sec,
> min.
>
> I guess this expiration method isnt too complex, but seems failsafe for me.
>
> Any comment?
>
> And a last question:
> This php pecl API allows any character in cache keys?
> As I seen the protocoll doesnt allow spaces, but in the php.net
> documentation doesnt say anything about keyname constraints.
>
> Thanks.
>
> --
> Veres Lajos
> vlajos at ludens.elte.hu
> +36 20 438 5909
>


More information about the memcached mailing list