Index: /trunk/Makefile.frag
===================================================================
--- /trunk/Makefile.frag	(revision 857)
+++ /trunk/Makefile.frag	(revision 858)
@@ -43,4 +43,4 @@
 xcachetest: all
 	$(SED) "s#\\./modules/#$(top_builddir)/modules/#" < $(srcdir)/xcache-test.ini > $(top_builddir)/tmp-php.ini
-	CC="$(CC)" \
-		$(srcdir)/run-xcachetest $(TESTS) $(TEST_ARGS) -c $(top_builddir)/tmp-php.ini
+	TEST_PHP_SRCDIR=$(srcdir) $(srcdir)/run-xcachetest $(TESTS) $(TEST_ARGS) -c $(top_builddir)/tmp-php.ini
+	$(srcdir)/run-xcachetest $(TESTS) $(TEST_ARGS) -c $(top_builddir)/tmp-php.ini
Index: /trunk/run-xcachetest
===================================================================
--- /trunk/run-xcachetest	(revision 857)
+++ /trunk/run-xcachetest	(revision 858)
@@ -20,9 +20,7 @@
 fi
 
-test -z "$PHP_SRC" && PHP_SRC=`getAbsolutePath ./php-src`
-
 TEST_PHP_EXECUTABLE="$php_cli"
 TEST_PHP_CGI_EXECUTABLE="$php_cgi"
-TEST_PHP_SRCDIR="$PHP_SRC"
+test -z "$TEST_PHP_SRCDIR" && TEST_PHP_SRCDIR=`getAbsolutePath ./php-src`
 
 export TEST_PHP_EXECUTABLE
Index: /trunk/tests/xcache_var.phpt
===================================================================
--- /trunk/tests/xcache_var.phpt	(revision 858)
+++ /trunk/tests/xcache_var.phpt	(revision 858)
@@ -0,0 +1,25 @@
+--TEST--
+xcache_set/get test
+--FILE--
+<?php
+var_dump(xcache_isset("a"));
+var_dump(xcache_set("a", 1));
+var_dump(xcache_get("a"));
+var_dump(xcache_isset("a"));
+var_dump(xcache_inc("a", 10));
+var_dump(xcache_get("a"));
+var_dump(xcache_dec("a", 5));
+var_dump(xcache_get("a"));
+xcache_unset("a");
+var_dump(xcache_isset("a"));
+?>
+--EXPECT--
+bool(false)
+bool(true)
+int(1)
+bool(true)
+int(11)
+int(11)
+int(6)
+int(6)
+bool(false)
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 857)
+++ /trunk/xcache.c	(revision 858)
@@ -338,9 +338,11 @@
 					xc_entry_php_t *xce_php = (xc_entry_php_t *) xce;
 					fresh = p_php->file_mtime == xce_php->file_mtime && p_php->php->file_size == xce_php->php->file_size;
-					break;
 				}
+				break;
 
 			case XC_TYPE_VAR:
-				fresh = 1;
+				{
+					fresh = !VAR_ENTRY_EXPIRED(p);
+				}
 				break;
 
@@ -2688,5 +2690,4 @@
 	xc_entry_var_t xce, *stored_xce;
 	zval *name;
-	int found = 0;
 
 	if (!xc_var_caches) {
@@ -2702,25 +2703,15 @@
 
 	ENTER_LOCK(cache) {
-		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) &xce TSRMLS_CC);
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			if (!VAR_ENTRY_EXPIRED(&stored_xce->entry)) {
-				found = 1;
-				xc_processor_restore_zval(return_value, stored_xce->value, stored_xce->have_references TSRMLS_CC);
-				/* return */
-				break;
-			}
-			else {
-				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
-			}
-		}
-
-		RETVAL_NULL();
+			/* return */
+			xc_processor_restore_zval(return_value, stored_xce->value, stored_xce->have_references TSRMLS_CC);
+			xc_cache_hit_dmz(cache TSRMLS_CC);
+		}
+		else {
+			RETVAL_NULL();
+			cache->misses ++;
+		}
 	} LEAVE_LOCK(cache);
-	if (found) {
-		xc_cache_hit_dmz(cache TSRMLS_CC);
-	}
-	else {
-		cache->misses ++;
-	}
 }
 /* }}} */
@@ -2771,5 +2762,4 @@
 	xc_entry_var_t xce, *stored_xce;
 	zval *name;
-	int found = 0;
 
 	if (!xc_var_caches) {
@@ -2787,23 +2777,13 @@
 		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			if (!VAR_ENTRY_EXPIRED(&stored_xce->entry)) {
-				found = 1;
-				RETVAL_TRUE;
-				/* return */
-				break;
-			}
-			else {
-				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
-			}
-		}
-
-		RETVAL_FALSE;
+			xc_cache_hit_dmz(cache TSRMLS_CC);
+			RETVAL_TRUE;
+			/* return */
+		}
+		else {
+			RETVAL_FALSE;
+		}
+
 	} LEAVE_LOCK(cache);
-	if (found) {
-		xc_cache_hit_dmz(cache TSRMLS_CC);
-	}
-	else {
-		cache->misses ++;
-	}
 }
 /* }}} */
@@ -2902,36 +2882,27 @@
 
 	ENTER_LOCK(cache) {
-		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) &xce TSRMLS_CC);
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
 			TRACE("incdec: gotxce %s", xce.entry.name.str.val);
-			/* timeout */
-			if (VAR_ENTRY_EXPIRED(&(stored_xce->entry))) {
-				TRACE("%s", "incdec: expired");
-				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
-				stored_xce = NULL;
-			}
-			else {
-				/* do it in place */
-				if (Z_TYPE_P(stored_xce->value) == IS_LONG) {
-					zval *zv;
-					stored_xce->entry.ctime = XG(request_time);
-					stored_xce->entry.ttl   = xce.entry.ttl;
-					TRACE("%s", "incdec: islong");
-					value = Z_LVAL_P(stored_xce->value);
-					value += (inc == 1 ? count : - count);
-					RETVAL_LONG(value);
-
-					zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_xce->value);
-					Z_LVAL_P(zv) = value;
-					break; /* leave lock */
-				}
-				else {
-					TRACE("%s", "incdec: notlong");
-					xc_processor_restore_zval(&oldzval, stored_xce->value, stored_xce->have_references TSRMLS_CC);
-					convert_to_long(&oldzval);
-					value = Z_LVAL(oldzval);
-					zval_dtor(&oldzval);
-				}
-			}
+			/* do it in place */
+			if (Z_TYPE_P(stored_xce->value) == IS_LONG) {
+				zval *zv;
+				stored_xce->entry.ctime = XG(request_time);
+				stored_xce->entry.ttl   = xce.entry.ttl;
+				TRACE("%s", "incdec: islong");
+				value = Z_LVAL_P(stored_xce->value);
+				value += (inc == 1 ? count : - count);
+				RETVAL_LONG(value);
+
+				zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_xce->value);
+				Z_LVAL_P(zv) = value;
+				break; /* leave lock */
+			}
+
+			TRACE("%s", "incdec: notlong");
+			xc_processor_restore_zval(&oldzval, stored_xce->value, stored_xce->have_references TSRMLS_CC);
+			convert_to_long(&oldzval);
+			value = Z_LVAL(oldzval);
+			zval_dtor(&oldzval);
 		}
 		else {
@@ -2941,5 +2912,5 @@
 		value += (inc == 1 ? count : - count);
 		RETVAL_LONG(value);
-		stored_xce->value = return_value;
+		xce.value = return_value;
 
 		if (stored_xce) {
