Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. PHP_FUNCTION(apc_fetch_info) {
  2.     zval *key;
  3.     apc_cache_entry_t* entry;
  4.     apc_cache_key_t slot_key;
  5.     time_t t;
  6.     char *strkey;
  7.     int strkey_len;
  8.     if(!APCG(enabled)) RETURN_FALSE;
  9.  
  10.     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &key) == FAILURE) {
  11.         return;
  12.     }
  13.  
  14.     t = apc_time();
  15.  
  16.     if(Z_TYPE_P(key) != IS_STRING && Z_TYPE_P(key) != IS_ARRAY) {
  17.         convert_to_string(key);
  18.     }
  19.    
  20.     if(Z_TYPE_P(key) == IS_STRING) {
  21.  
  22.         strkey = Z_STRVAL_P(key);
  23.         strkey_len = Z_STRLEN_P(key);
  24.         if(!strkey_len) RETURN_FALSE;
  25.        
  26.         entry = apc_cache_user_find(apc_user_cache, strkey, (strkey_len + 1), t TSRMLS_CC);
  27.         if(!entry) {
  28.             RETURN_FALSE;
  29.         }
  30.  
  31.         slot_t* slot = apc_cache_find_slot(apc_user_cache, slot_key, t TSRMLS_CC);
  32.         array_init(return_value);
  33.         add_assoc_long(return_value, "ttl", entry->data.user.ttl);
  34.         add_assoc_long(return_value, "num_hits", slot->num_hits);
  35.  
  36.     } else if(Z_TYPE_P(key) == IS_ARRAY) {
  37.        
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement