Re: Solution for writing a function layer between pecl-memcache and PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ppp and static / non-static are unrelated topics.
the former is regarding access control or visibility into the members
(variables or methods) of a class.
the latter is regarding whether a member can be called from the context of
an instance or not.  essentially
static means to associate a function w/ a class.  this function need not use
the instance data in order to
complete its objective.  it is important to note that means static
methods cannot
have access to instance
data; ie a static method cannot use the $this keyword.  there are
staticvariables as well and they behave
in a similar manner.
for ppp the documentation on php.net should be sufficient.  regarding the
caching concept, what you would
cache is the values of instance variables in the object instances.  so the
number of lines in the file doesnt matter
much, because if you were to split the large class into several smaller
classes and use a caching approach you
would essentially be caching the same thing with the 2 implementations.  the
purpose of breaking down the classes
into a small number of lines is so that they are easy to maintain.  a design
principle is to separate the responsibilities
of each class so that they typically have only 1 responsibility.

-nathan

On 7/27/07, Sascha Braun - CEO @ Braun Networks <sascha@xxxxxxxxxxxxxxxxxx>
wrote:
>
> I checked out the book from mister rethans and mister gutmans
> and mister bakken, mh, its seems easier to simply say how the
> book is named :))
>
> To check out, what exactly it means, to create static and public
> and so on methods. Yeah, I can easely call them static, as you
> prefered.
>
> But now there came up a new question in me.
>
> Is there a perforamce issue about using public privat static and
> so on methods. Will my application even start to run faster?
>
> And another question I would like to ask is, that one of my classes
> as prescribed is allready 400 KB in size, does it slow down the sys-
> tem more to load that class, into memcached, or additionally
> eaccelerator than splitting the class in a hole bunch of smaller
> classes, which are getting loaded, as needed too.
>
> Thanks you!
>
> Am Freitag, den 27.07.2007, 14:38 -0400 schrieb Nathan Nobbe:
> > judging by the method invocation you have shown
> >
> > site::memcache($pointername, $dataset);
> >
> > that indicates site is a class and memecahce is a method defined in
> site,
> > which is being invoked statically in this case.
> > and in the definition of memecache you showed, the definition does not
> have
> > the static keyword, therefore you
> > should not be invoking it from a static context.
> > from the documentation on the static keyword
> > Calling non-static methods statically generates an E_STRICT level
> warning.
> >
> > its not a solution to your problem but it is a point on proper style.
> >
> > -nathan
> >
> > On 7/27/07, Sascha Braun - CEO @ Braun Networks <
> sascha@xxxxxxxxxxxxxxxxxx>
> > wrote:
> > >
> > > Hi dear Sancar,
> > >
> > > you seem really the best man in place as what I see in the mailing
> > > list :)) Thats really lovely I would like to say.
> > >
> > > Now lets come to the solution I need:
> > >
> > > public function memcache($pointer, $data="", $compress="",
> $timeout="0")
> > > // store or load data from the memcache
> > > {
> > > if (MEMCACHE_SUPPORT == 'true') {
> > > $memcached_port = $_SESSION['memcache_port'];
> > > if (empty($memcached_port)) { $memcached_port = '99999'; }
> > > $memcache = memcache_connect('localhost', $memcached_port);
> > > if ($memcache) {
> > > $memcache_pointer = PROJECT.$pointer;
> > > $cache = $memcache -> get($memcache_pointer);
> > > if (!$cache) {
> > > $memcache->set($memcache_pointer,$data);
> > > $cache = $memcache -> get($memcache_pointer);
> > > }
> > > return $cache;
> > > }
> > > }
> > > }
> > >
> > > This is the Funktion I use to load and write data to the memcache
> > > a write or restore looks like this here
> site::memcache('pointer',$data);
> > >
> > > This is working in many cases pretty fine.
> > >
> > > Now I have a codepart, where the 'pointer' is getting created
> dynamical-
> > > ly. Which means I do fx. a $content_id.'_'.$translation instead of
> wri-
> > > ting a simple 'pointer' as first parameter to the above function.
> > >
> > > When I now call my XML Parser, to store data in memcache, and try to
> > > recall, the data short after, it says:
> > >
> > > File not found: This file somewhere in the suburbs.
> > >
> > > But when I try to output the XML Object before the data is written to
> > > the cache, everything goes terribly fine.
> > >
> > > Now I figured out, that when I use static naming for the memcache data
> > > pointer 'pointer' everything goes fine.
> > >
> > > When I use the memcache directly, which means, I call the
> > > $memcache->set() and $memcache->get() function from where I store data
> > > everything goes fine again, even with dynamically created, variables.
> > >
> > > But as soon as I use my function layer, call a to
> > > site::memcache($pointername,$dataset); only  returnes bullshit.
> > >
> > > Mh, this makes me a little bit sad.
> > >
> > > Maybe somebody or even you, can help me :))
> > >
> > > Best Regards, and a baba Respect from Germany, Dear Sancar!
> > >
> > > Sascha
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux