search
HomeBackend DevelopmentPHP TutorialDiscuss the detailed explanation of API development using eAccelerator in PHP_PHP Tutorial
Discuss the detailed explanation of API development using eAccelerator in PHP_PHP TutorialJul 21, 2016 pm 03:07 PM
apieacceleratorphpuseanddevelopDiscussdocumentofDetailed explanationillustrate

1. API and documentation description:
eAccelerator provides a convenient and stable native cache implementation. Since most of the code implementation is based on shared memory, it can only be implemented in *nix platform is used, and Windows platform Michael does not know when this support will be available.
eAccelerator provides the following API interfaces and files: (The following files are in the doc/php/ directory of the source code package)
File list:

Copy code The code is as follows:

cache.php
dasm.php
encoder.php
info.php
loader.php
session.php
shared_memory.php

Interface list:
Copy code The code is as follows:

array eaccelerator_cached_scripts ()
void eaccelerator_cache_output (string $key, string $eval_code, [int $ttl = 0])
void eaccelerator_cache_page (string $key, [int $ttl = 0])
void eaccelerator_cache_result (string $key, string $code, [int $ttl = 0])
void eaccelerator_caching (boolean $flag)
void eaccelerator_clean ()
void eaccelerator_clear ()
array eaccelerator_dasm_file (mixed $filename)
mixed eaccelerator_encode (mixed $src, [mixed $prefix = ''], [string $pre_content = ''] , [string $post_content = ''])
void eaccelerator_gc ()
mixed eaccelerator_get (string $key)
array eaccelerator_info ()
array eaccelerator_list_keys ()
void eaccelerator_load ()
boolean eaccelerator_lock (string $key)
void eaccelerator_optimizer (boolean $flag)
void eaccelerator_purge ()
boolean eaccelerator_put (string $key, mixed $value, [int $ttl = 0])
array eaccelerator_removed_scripts ()
boolean eaccelerator_rm (string $key)
void eaccelerator_rm_page (string $key)
boolean eaccelerator_set_session_handlers ()
boolean eaccelerator_unlock (string $key)

Here are the interface descriptions translated by some netizens:
Copy the code The code is as follows:

eaccelerator_put($key, $value, $ttl=0)
Save $value into the cache with $key as the key name (object type is supported under php4, but looking at the source code, it seems that it is not supported in zend2 ), $ttl is the life cycle of this cache, in seconds. Omitting this parameter or specifying it as 0 means there is no time limit until the server is restarted and cleared.

eaccelerator_get($key)
Returns the data stored in the corresponding eaccelerator_put() from the cache according to $key. If the cache has expired or does not exist, the return value is NULL

eaccelerator_rm($key)
Remove cache according to $key

eaccelerator_gc()
Remove and clean up all expired keys

eaccelerator_lock($key)
as $key plus locking operation to ensure data synchronization during multi-process and multi-thread operations. You need to call eaccelerator_unlock($key) to release this lock or wait for the program request to automatically release this lock.
For example:
eaccelerator_lock(“count”);
eaccelerator_put(“count”,eaccelerator_get(“count”)+1));
?>

eaccelerator_unlock($key)
Release the lock based on $key

eaccelerator_cache_output($key, $eval_code, $ttl=0)
Cache the output of the $eval_code code for $ttl seconds, ($ttl parameter is the same as eacclerator_put)
For example:


eaccelerator_cache_result ($key, $eval_code, $ttl=0)
Cache the execution result of the $eval_code code for $ttl seconds, ($ttl parameter is the same as eacclerator_put), similar to cache_output
For example:


eaccelerator_cache_page($key, $ttl=0)
Cache the current entire page for $ttl seconds.
For example:
eaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30);
echo time();
phpinfo();
?>

eaccelerator_rm_page($key)
Delete the cache executed by eaccelerator_cache_page(), the parameter is also $key

2. Use eAccelerator to accelerate PHP code
In addition, support for eAccelerator has been integrated in PHPCMS. The following is a piece of code from PHPCMS
Copy code The code is as follows:

class cache
{
function __construct()
{
}

function cache()
{
$this->__construct();
}

function get($name)
{
return eaccelerator_get($name);
}

function set($name, $value, $ttl = 0)
{
eaccelerator_lock($name);
return eaccelerator_put($name, $value, $ ttl);
}

function rm($name)
{
return eaccelerator_rm($name);
}

function clear()
{
return eaccelerator_gc();
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327534.htmlTechArticle1. API and documentation description: eAccelerator provides a convenient, convenient and stable native cache implementation method. Part of the code implementation is based on shared memory, so it can only be used on *nix platforms...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php怎么设置implode没有分隔符php怎么设置implode没有分隔符Apr 18, 2022 pm 05:39 PM

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

深入探讨:Django框架是什么?深入探讨:Django框架是什么?Jan 19, 2024 am 09:23 AM

Django框架是一种用于Web应用程序的Python框架,它提供了一个简单而强大的方式来创建Web应用程序。事实上,Django已经成为当前最受欢迎的PythonWeb开发框架之一,也成为很多公司的首选,包括Instagram和Pinterest。本文将深入探讨Django框架是什么,包括基础概念和重要组件,以及具体代码示例。Django基础概念Djan

深入探讨Laravel中的Head请求方法深入探讨Laravel中的Head请求方法Mar 06, 2024 pm 03:36 PM

作为一个流行的PHP框架,Laravel提供了许多便捷的请求方法来处理不同类型的HTTP请求。其中,Head请求方法是一个比较特殊且常被忽视的方法。在本文中,我们将深入探讨Laravel中Head请求方法的作用、用法和示例代码。什么是Head请求方法?Head请求方法是HTTP协议中定义的一种请求方法,在发送Head请求时,服务器将仅返回请求头信息,而不会返

深入探讨Go语言对C语言的兼容程度深入探讨Go语言对C语言的兼容程度Mar 07, 2024 pm 02:45 PM

Go语言是一门由Google开发的编程语言,具有高效、简洁、并发性强等特点。它在语法结构、包管理、高级特性等方面都有很大的优势,因此备受程序员青睐。然而,在实际开发中,很多项目会涉及到与传统的编程语言C进行交互,因此Go语言与C语言的兼容性就显得尤为重要。首先,我们来谈谈Go语言与C语言的兼容性。在Go语言中,可以通过CGo将Go语言与C语言进行交互。CGo

深入探讨:Go语言中的单线程特性深入探讨:Go语言中的单线程特性Mar 15, 2024 pm 02:09 PM

Go语言作为一种现代化的编程语言,以其简洁高效的特性在近年来受到越来越多开发者的喜爱和青睐。其中一个让人独特的地方就是其单线程特性。在传统的多线程编程语言中,开发者通常需要手动管理线程之间的同步和互斥,而在Go语言中,借助其独特的协程(Goroutine)和通信机制(channel),可以方便且高效地实现并发编程。一、Goroutine与单线程:Go语言中的

深入探讨:Golang是否适合编写驱动程序?深入探讨:Golang是否适合编写驱动程序?Mar 20, 2024 am 10:09 AM

Golang是一种由谷歌开发的编程语言,其出色的性能和并发特性使其在各种领域中得到了广泛的应用,包括网络编程、大数据处理等。然而,对于一些需要直接操作硬件的领域,比如驱动程序开发,人们可能会开始思考:Golang是否适合用于编写驱动程序呢?本文将深入探讨这个问题,并通过具体的代码示例来展示Golang在驱动程序开发中的应用。首先,让我们来了解一下什么是驱动程

深入探讨Linux中常见的特殊字符深入探讨Linux中常见的特殊字符Mar 14, 2024 pm 02:54 PM

Linux操作系统作为一种常用的开源操作系统,具有强大的可定制性和灵活性。在使用Linux系统时,我们经常会遇到各种特殊字符的处理。这些特殊字符在命令行中具有特殊的含义,能够实现很多高级功能。本文将深入探讨Linux中常见的特殊字符,并结合具体的代码示例来详细介绍它们的用法。通配符:通配符是用来匹配文件名的特殊字符,常见的通配符包括*、?、[]等。下面是几种

Golang的本质是脚本语言还是编译语言?探讨Golang的本质是脚本语言还是编译语言?探讨Mar 19, 2024 pm 03:12 PM

Golang的本质是脚本语言还是编译语言?探讨Golang,也被称为Go语言,是一种由Google开发的静态类型编程语言。自诞生以来,Golang一直备受开发者关注,其优秀的并发性能、简洁的语法和跨平台特性使其在各个领域得到广泛应用。然而,关于Golang到底是脚本语言还是编译语言,却一直存在着争议。脚本语言和编译语言在运行时的不同方式给人们留下了深刻的印象

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft