Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Optimization + bug fixes #1093

Merged
merged 22 commits into from Aug 15, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Phalcon\Cache\Frontend\Json optimizations
  • Loading branch information
sjinks committed Aug 15, 2013
commit 533356359596a5fcc346ab9ca67a74a6f18af866
98 changes: 3 additions & 95 deletions ext/cache/frontend/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,100 +74,11 @@
*/
PHALCON_INIT_CLASS(Phalcon_Cache_Frontend_Json){

PHALCON_REGISTER_CLASS(Phalcon\\Cache\\Frontend, Json, cache_frontend_json, phalcon_cache_frontend_json_method_entry, 0);

zend_declare_property_null(phalcon_cache_frontend_json_ce, SL("_frontendOptions"), ZEND_ACC_PROTECTED TSRMLS_CC);
PHALCON_REGISTER_CLASS_EX(Phalcon\\Cache\\Frontend, Json, cache_frontend_json, "phalcon\\cache\\frontend\\data", phalcon_cache_frontend_json_method_entry, 0);

zend_class_implements(phalcon_cache_frontend_json_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce);

return SUCCESS;
}

/**
* Phalcon\Cache\Frontend\Base64 constructor
*
* @param array $frontendOptions
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, __construct){

zval *frontend_options = NULL;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 0, 1, &frontend_options);

if (!frontend_options) {
PHALCON_INIT_VAR(frontend_options);
}

phalcon_update_property_this(this_ptr, SL("_frontendOptions"), frontend_options TSRMLS_CC);

PHALCON_MM_RESTORE();
}

/**
* Returns the cache lifetime
*
* @return integer
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, getLifetime){

zval *options, *lifetime;

PHALCON_MM_GROW();

PHALCON_OBS_VAR(options);
phalcon_read_property_this(&options, this_ptr, SL("_frontendOptions"), PH_NOISY_CC);
if (Z_TYPE_P(options) == IS_ARRAY) {
if (phalcon_array_isset_string(options, SS("lifetime"))) {
PHALCON_OBS_VAR(lifetime);
phalcon_array_fetch_string(&lifetime, options, SL("lifetime"), PH_NOISY);
RETURN_CCTOR(lifetime);
}
}

PHALCON_MM_RESTORE();
RETURN_LONG(1);
}

/**
* Check whether if frontend is buffering output
*
* @return boolean
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, isBuffering){


RETURN_FALSE;
}

/**
* Starts output frontend. Actually, does nothing
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, start){



}

/**
* Returns output cached content
*
* @return string
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, getContent){


RETURN_NULL();
}

/**
* Stops output frontend
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, stop){



}

/**
Expand All @@ -180,8 +91,7 @@ PHP_METHOD(Phalcon_Cache_Frontend_Json, beforeStore){

zval *data;

phalcon_fetch_params(1, 1, 0, &data);

phalcon_fetch_params(0, 1, 0, &data);
phalcon_json_encode(return_value, return_value_ptr, data, 0 TSRMLS_CC);
}

Expand All @@ -195,8 +105,6 @@ PHP_METHOD(Phalcon_Cache_Frontend_Json, afterRetrieve){

zval *data;

phalcon_fetch_params(1, 1, 0, &data);

phalcon_fetch_params(0, 1, 0, &data);
phalcon_json_decode(return_value, return_value_ptr, data, 0 TSRMLS_CC);
}

17 changes: 0 additions & 17 deletions ext/cache/frontend/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@ extern zend_class_entry *phalcon_cache_frontend_json_ce;

PHALCON_INIT_CLASS(Phalcon_Cache_Frontend_Json);

PHP_METHOD(Phalcon_Cache_Frontend_Json, __construct);
PHP_METHOD(Phalcon_Cache_Frontend_Json, getLifetime);
PHP_METHOD(Phalcon_Cache_Frontend_Json, isBuffering);
PHP_METHOD(Phalcon_Cache_Frontend_Json, start);
PHP_METHOD(Phalcon_Cache_Frontend_Json, getContent);
PHP_METHOD(Phalcon_Cache_Frontend_Json, stop);
PHP_METHOD(Phalcon_Cache_Frontend_Json, beforeStore);
PHP_METHOD(Phalcon_Cache_Frontend_Json, afterRetrieve);

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_cache_frontend_json___construct, 0, 0, 0)
ZEND_ARG_INFO(0, frontendOptions)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_cache_frontend_json_beforestore, 0, 0, 1)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
Expand All @@ -43,14 +33,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_cache_frontend_json_afterretrieve, 0, 0,
ZEND_END_ARG_INFO()

PHALCON_INIT_FUNCS(phalcon_cache_frontend_json_method_entry){
PHP_ME(Phalcon_Cache_Frontend_Json, __construct, arginfo_phalcon_cache_frontend_json___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Phalcon_Cache_Frontend_Json, getLifetime, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, isBuffering, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, start, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, getContent, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, stop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, beforeStore, arginfo_phalcon_cache_frontend_json_beforestore, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_Frontend_Json, afterRetrieve, arginfo_phalcon_cache_frontend_json_afterretrieve, ZEND_ACC_PUBLIC)
PHP_FE_END
};