first commit

This commit is contained in:
2014-03-26 14:18:20 +08:00
commit 41681f1f18
31 changed files with 4496 additions and 0 deletions

38
engine/lib/Cache.class.php Executable file
View File

@ -0,0 +1,38 @@
<?php
Class Cache{
const CACHEDB = 'SaeMemcache';
private static $mmc = false;
private static $cacheGet = array();
private static function init(){
if( self::$mmc === false ){
self::$mmc = memcache_init();
}
}
public static function get($key){
if( !self::$cacheGet[$key] ){
self::init();
if( self::$mmc === false ){
return;
}
self::$cacheGet[$key] = memcache_get(self::$mmc,$key);
}
return self::$cacheGet[$key];
}
public static function set( $key , $value , $time = 18000 ){
if( !self::$cacheGet[$key] ){
self::$cacheGet[$key] = $value;
}
self::init();
if( self::$mmc === false ){
return;
}
memcache_set( self::$mmc , $key ,$value , false , $time );
}
public static function increment( $key , $value = 1 ){
if( !self::$cacheGet[$key] ){
self::$cacheGet[$key] += $value;
}
self::init();
return memcache_increment( self::$mmc , $key ,$value );
}
}