Overview

Namespaces

  • Kotchasan
    • Cache
    • Database
    • Http
    • Log
    • Orm
  • None
  • PHP
  • Psr
    • Cache
    • Http
      • Message
    • Log

Classes

  • ArrayIterator
  • DateInterval
  • DOMNode
  • Kotchasan
  • Kotchasan\Accordion
  • Kotchasan\ApiController
  • Kotchasan\ArrayTool
  • Kotchasan\Cache\ApcCache
  • Kotchasan\Cache\Cache
  • Kotchasan\Cache\CacheItem
  • Kotchasan\Cache\FileCache
  • Kotchasan\CKEditor
  • Kotchasan\Collection
  • Kotchasan\Config
  • Kotchasan\Controller
  • Kotchasan\Country
  • Kotchasan\Csv
  • Kotchasan\Curl
  • Kotchasan\Currency
  • Kotchasan\Database
  • Kotchasan\Database\Db
  • Kotchasan\Database\DbCache
  • Kotchasan\Database\Driver
  • Kotchasan\Database\PdoMysqlDriver
  • Kotchasan\Database\Query
  • Kotchasan\Database\QueryBuilder
  • Kotchasan\Database\Schema
  • Kotchasan\Database\Sql
  • Kotchasan\DataTable
  • Kotchasan\Date
  • Kotchasan\DOMNode
  • Kotchasan\DOMParser
  • Kotchasan\Email
  • Kotchasan\File
  • Kotchasan\Files
  • Kotchasan\Form
  • Kotchasan\Grid
  • Kotchasan\Html
  • Kotchasan\Htmldoc
  • Kotchasan\HtmlTable
  • Kotchasan\Http\AbstractMessage
  • Kotchasan\Http\AbstractRequest
  • Kotchasan\Http\Message
  • Kotchasan\Http\NotFound
  • Kotchasan\Http\Request
  • Kotchasan\Http\Response
  • Kotchasan\Http\Stream
  • Kotchasan\Http\UploadedFile
  • Kotchasan\Http\Uri
  • Kotchasan\Image
  • Kotchasan\InputItem
  • Kotchasan\Inputs
  • Kotchasan\KBase
  • Kotchasan\Language
  • Kotchasan\ListItem
  • Kotchasan\Log\AbstractLogger
  • Kotchasan\Log\Logger
  • Kotchasan\Login
  • Kotchasan\Menu
  • Kotchasan\Mime
  • Kotchasan\Model
  • Kotchasan\Number
  • Kotchasan\ObjectTool
  • Kotchasan\Orm\Field
  • Kotchasan\Orm\Recordset
  • Kotchasan\Password
  • Kotchasan\Pdf
  • Kotchasan\Province
  • Kotchasan\Router
  • Kotchasan\Session
  • Kotchasan\Singleton
  • Kotchasan\Tab
  • Kotchasan\TableRow
  • Kotchasan\Template
  • Kotchasan\Text
  • Kotchasan\Validator
  • Kotchasan\View
  • PHPMailer
  • Psr\Log\AbstractLogger
  • Psr\Log\LogLevel
  • Psr\Log\NullLogger
  • SMTP

Interfaces

  • ArrayAccess
  • Countable
  • DateTimeInterface
  • Iterator
  • IteratorAggregate
  • Psr\Cache\CacheItemInterface
  • Psr\Cache\CacheItemPoolInterface
  • Psr\Http\Message\MessageInterface
  • Psr\Http\Message\RequestInterface
  • Psr\Http\Message\ResponseInterface
  • Psr\Http\Message\ServerRequestInterface
  • Psr\Http\Message\StreamInterface
  • Psr\Http\Message\UploadedFileInterface
  • Psr\Http\Message\UriInterface
  • Psr\Log\LoggerAwareInterface
  • Psr\Log\LoggerInterface
  • SeekableIterator
  • Serializable
  • Traversable

Traits

  • Psr\Log\LoggerTrait

Exceptions

  • Exception
  • InvalidArgumentException
  • Kotchasan\ApiException
  • Kotchasan\Cache\Exception
  • Kotchasan\Database\Exception
  • Kotchasan\InputItemException
  • LogicException
  • phpmailerException
  • RuntimeException

Functions

  • createClass
  • debug
  • getClassPath
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * @filesource  Kotchasan/Cache/ApcCache.php
  4:  *
  5:  * @copyright 2016 Goragod.com
  6:  * @license http://www.kotchasan.com/license/
  7:  *
  8:  * @see http://www.kotchasan.com/
  9:  */
 10: 
 11: namespace Kotchasan\Cache;
 12: 
 13: use Kotchasan\Cache\CacheItem as Item;
 14: use Psr\Cache\CacheItemInterface;
 15: 
 16: /**
 17:  * APC cache driver.
 18:  *
 19:  * @author Goragod Wiriya <admin@goragod.com>
 20:  *
 21:  * @since 1.0
 22:  */
 23: class ApcCache extends Cache
 24: {
 25:     /**
 26:      * Class constructor
 27:      *
 28:      * @throws Exception ถ้า Server ไม่รองรับ APC
 29:      */
 30:     public function __construct()
 31:     {
 32:         if (!extension_loaded('apc') || !is_callable('apc_fetch')) {
 33:             throw new \Exception('APC not supported.');
 34:         }
 35:     }
 36: 
 37:     /**
 38:      * เคลียร์แคช
 39:      * คืนค่า true ถ้าลบเรียบร้อย, หรือ false ถ้าไม่สำเร็จ.
 40:      *
 41:      * @return bool
 42:      */
 43:     public function clear()
 44:     {
 45:         return \apc_clear_cache('user');
 46:     }
 47: 
 48:     /**
 49:      * ลบแคชหลายๆรายการ
 50:      * คืนค่า true ถ้าสำเร็จ, false ถ้าไม่สำเร็จ.
 51:      *
 52:      * @param array $keys
 53:      *
 54:      * @return bool
 55:      */
 56:     public function deleteItems(array $keys)
 57:     {
 58:         if ($this->cache_dir) {
 59:             foreach ($keys as $key) {
 60:                 \apc_delete($key);
 61:             }
 62:         }
 63: 
 64:         return true;
 65:     }
 66: 
 67:     /**
 68:      * อ่านแคชหลายรายการ.
 69:      *
 70:      * @param array $keys
 71:      *
 72:      * @return array
 73:      */
 74:     public function getItems(array $keys = array())
 75:     {
 76:         $resuts = array();
 77:         $success = false;
 78:         $values = \apc_fetch($keys, $success);
 79:         if ($success && is_array($values)) {
 80:             foreach ($values as $key => $value) {
 81:                 $item = new Item($key);
 82:                 $resuts[$key] = $item->set($value);
 83:             }
 84:         }
 85: 
 86:         return $resuts;
 87:     }
 88: 
 89:     /**
 90:      * ตรวจสอบแคช
 91:      * คืนค่า true ถ้ามี.
 92:      *
 93:      * @param string $key
 94:      *
 95:      * @return bool
 96:      */
 97:     public function hasItem($key)
 98:     {
 99:         return \apc_exists($key);
100:     }
101: 
102:     /**
103:      * บันทึกแคช
104:      * สำเร็จคืนค่า true ไม่สำเร็จคืนค่า false.
105:      *
106:      * @param CacheItemInterface $item
107:      *
108:      * @throws CacheException
109:      *
110:      * @return bool
111:      */
112:     public function save(CacheItemInterface $item)
113:     {
114:         return \apc_store($item->getKey(), $item->get(), self::$cfg->get('cache_expire', 5));
115:     }
116: }
117: 
Kotchasan API documentation generated by ApiGen