Welcome Guest, Not a member yet? Register   Sign In
CachedObjects v1.2 - cache granularity as you want
#11

[eluser]mglinski[/eluser]
Big Grin
#12

[eluser]sdbruder[/eluser]
Tonight I'll treat the corner cases (memcache down, etcetera) with the apropriate log(debug) messages and some degree of documentation.

Now my 2 girls wait me (wife and daughter) Smile
#13

[eluser]sdbruder[/eluser]
CachedObjects v1.3 released

http://sergio.bruder.com.br/cachedobjects/

NEW in v1.3
---------

- modularized backends for cache.
- new backend, memcache.
- now under version control
- now with makefile to create the packages, documentation, Changelog, site and upload it, all automagically. :p

grab it while it's still hot! Smile
#14

[eluser]mglinski[/eluser]
[quote author="sdbruder" date="1214128859"]CachedObjects v1.3 released

http://sergio.bruder.com.br/cachedobjects/

NEW in v1.3
---------

- modularized backends for cache.
- new backend, memcache.
- now under version control
- now with makefile to create the packages, documentation, Changelog, site and upload it, all automagically. :p

grab it while it's still hot! Smile[/quote]
Seems to be missing the 2 helper files codeigniter_helper and memcache_helper
I would also suggest that you namespace these files like:
co_codeigniter_helper.php and co_memcache_helper.php to avoid collisions, I know I already have a memcache helper. Wink
Also, if its not to much to ask, could you convert the docs to the CI type(here) it would help a lot of us that dont have linux or cygwin.
-Matt
#15

[eluser]sdbruder[/eluser]
XtraFile, published v1.3.1 with the missing files. renamed the files when apropriate to co_ as you sugested, too.

The documentation change will have to wait v1.4.
#16

[eluser]chmod[/eluser]
Hello,it's very intersting code.
My develope ENV is windows XP.
and it has installed memcached.
I download CachedObject-1.3.1.tar.gz(http://sergio.bruder.com.br/cachedobject...ar.gz),and unpack it.
when I first run examplepage, an error occur:
Code:
A PHP Error was encountered
Severity: Notice
Message: Constant MEMCACHE_COMPRESSED already defined
Filename: helpers/co_memcached_helper.php
Line Number: 92

when I comment this line, the examplepage is OK.

and I restart memcached service,another occured:
Code:
A PHP Error was encountered
Severity: Notice
Message: fwrite() [function.fwrite]: send of 38 bytes failed with errno=10054 Զ�����ǿ�ȹر���һ�����е���ӡ�
Filename: helpers/co_memcached_helper.php
Line Number: 395

how to fix the bugs?
#17

[eluser]Gamesh[/eluser]
Nice peace of code. Thanks, i added minor modifications to it.

Code:
function __call ($member, $arguments) {
        $this->load->helper( array('co_cachedobjects','co_memcached') );
        $this->load->library(co_loadbackend());
        return co_call(&$this, $member, $arguments, $this->methodcache_expiration);
    }

I think helpers and library should be loaded only when needed, not in the constructor.
And in some cases helper functions can't be found in __call method, if loaded inside __call works fine.

the call_user_method_array is deprecated should be replaced with call_user_func_array
Code:
function co_call(&$obj, $member, $arguments, $expiration)
    {
        $CI =& get_instance();
        $class = get_class($obj);
        $fn_id = array($class,$member,$arguments);

        if (substr($member,-6) == 'Cached')
        {
            $method_name = substr($member,0,-6);            
            if (method_exists($obj,$method_name))
            {
                if ($expiration > 0)
                {
                    if (!$CI->co_backend->get($fn_id, &$ret))
                    {
                        $ret = call_user_func_array( array(&$obj, $method_name), $arguments);
                        if (! $CI->co_backend->write($fn_id, $ret, $expiration) )
                        {
                            log_message('debug', "cachedobjects: cant write cache for $class->$member");
                        }
                    }
                }
                else
                {
                    $ret = call_user_func_array( array(&$obj, $method_name), $arguments);
                }
                return $ret;
            } else
            {
                throw new Exception("Call to undefined method ".$class."::{$method_name}()");
            }
        } else
        {
            throw new Exception("Call to undefined method ".$class."::{$method_name}()");
        }
    }

about the mkid function i think it should be changed to serialize instead of foreach and concating, that way any arguments could be processed.
Code:
function mkid($id) {
    // Build the id.  The name is an MD5 hash of the $id array        
    return md5(serialize($id));
}

oh and i changed cache storing a bit, cache files are now created in class_name subfolder for easy cache flushing. see method flush(class_name). somehow your class didn't have cache flushing, and i like to cache files for a very long time, but to flush the cache if anything changes. Like if you have content that doesn't change often but you need changes to take effect immediately.
Code:
$this->flush(__CLASS__);

Hope this is useful to anybody. attached the Co_backend_ci file.




Theme © iAndrew 2016 - Forum software by © MyBB