php memecache 缓存分组纳闷
php memecache 缓存分组疑惑
在php memcache缓存里,我只找到 add,delete两种方法添加或删除缓存,没有分组功能
像JAVA版 memecache有分组功能,如我用一个用户日记分组 当我更新了日记,可以删除此日记分组缓存,我的个人日记列表,我的WAP版日记列表也更新
我想有如何功能
add("cacheGroup","cacheName1",$value1);
add("cacheGroup","cacheName2",$value2);
add("cacheGroup","cacheName3",$value3);
deleteGroup("cacheGroup");
然后上面三个缓存都清除
php memecache缓存API如下
Memcache::add ― 添加一个值,如果已经存在,则返回false
Memcache::addServer ― 添加一个可供使用的服务器地址
Memcache::close ― 关闭一个Memcache对象
Memcache::connect ― 创建一个Memcache对象
memcache_debug ― 控制调试功能
Memcache::decrement ― 对保存的某个key中的值进行减法操作
Memcache::delete ― 删除一个key值
Memcache::flush ― 清除所有缓存的数据
Memcache::get ― 获取一个key值
Memcache::getExtendedStats ― 获取进程池中所有进程的运行系统统计
Memcache::getServerStatus ― 获取运行服务器的参数
Memcache::getStats ― 返回服务器的一些运行统计信息
Memcache::getVersion ― 返回运行的Memcache的版本信息
Memcache::increment ― 对保存的某个key中的值进行加法操作
Memcache::pconnect ― 创建一个Memcache的持久连接对象
Memcache::replace ― R对一个已有的key进行覆写操作
Memcache::set ― 添加一个值,如果已经存在,则覆写
Memcache::setCompressThreshold ― 对大于某一大小的数据进行压缩
Memcache::setServerParams ― 在运行时修改服务器的参数
------解决方案--------------------
add("cacheGroup","cacheName1",$value1);
add("cacheGroup","cacheName2",$value2);
add("cacheGroup","cacheName3",$value3);
deleteGroup("cacheGroup");
这样也就是一个key 控制一数组
- PHP code
class mem { public $memcache=null; public $array=array(); public function __construct() { $this->memcache = new Memcache; $this->memcache->connect('localhost', 11211) or die ("Could not connect"); } public function add($parent="",$key="",$value="") { $this->array[$key]=$value; $this->memcache->set($parent,$this->array,false,500); } public function deleteGroup($key=null) { $this->memcache->delete($key); } public function get($key=null) { return $this->memcache->get($key); } } $mem=new mem(); $mem->add("cacheGroup","cacheName1","1"); $mem->add("cacheGroup","cacheName2","2"); $mem->add("cacheGroup","cacheName3","3"); //$mem->deleteGroup("cacheGroup"); var_Dump($mem->get('cacheGroup')); <br><font color="#e78608">------解决方案--------------------</font><br> <br>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In web development, we often need to use caching technology to improve website performance and response speed. Memcache is a popular caching technology that can cache any data type and supports high concurrency and high availability. This article will introduce how to use Memcache in PHP development and provide specific code examples. 1. Install Memcache To use Memcache, we first need to install the Memcache extension on the server. In CentOS operating system, you can use the following command

When playing games such as Grand Theft Auto V, many players like to use Mods to increase the fun and playability of the game. As a well-known Mod management tool, OpenIV can simplify the Mod installation and management process. So, let’s take a look at how to add Mod to OpenIV. First, you need to make sure you have downloaded and installed OpenIV. It can be found on the official website of OpenIV (https://openiv.com/)

With the rapid development of the Internet, more and more applications need to face a large number of concurrent requests. How to improve the concurrent processing capabilities of applications has become a problem that developers need to solve. Among them, using Memcache caching technology for concurrency optimization has become a relatively popular solution. Memcache is an efficient caching technology suitable for large-scale web applications, databases and distributed systems. Its characteristic is to store data in memory to achieve high-speed read and write operations. During the data access process of web applications,

In PHP development, using the Memcache caching system can greatly improve the efficiency of data reading and writing. Memcache is a memory-based caching system that can cache data in memory to avoid frequent reading and writing of the database. This article will introduce how to use Memcache in PHP for efficient data reading and writing operations, and provide specific code examples. 1. Install and configure Memcache First, you need to install the Memcache extension on the server. able to pass

PHP is a very popular programming language commonly used for server-side web application development. As the user scale of web applications continues to grow and the amount of data continues to increase, efficient data caching and sorting operations become more and more important. Memcache is a very useful tool in this situation. This article will introduce how to use Memcache to achieve efficient data caching and sorting operations in PHP development, and provide specific code examples. What is Memcache? Memcache is

As web applications become increasingly complex, performance has become a critical issue. In many applications, database queries are one of the most time-consuming operations. In order to avoid frequently reading data from the database, a caching system can be used to store frequently read data in memory for quick access. In PHP development, using Memcached for distributed caching is an extremely common practice. In this article we will introduce how to use Memcached for distributed caching. What is Memca

How to use Memcache to optimize data storage operations in your PHP application? In web application development, data storage is a crucial link. In PHP applications, Memcache, as a memory cache system, can effectively improve the efficiency of data storage and reading operations. This article will introduce how to use Memcache to optimize data storage operations in PHP applications, and attach specific code examples. Step 1: Install the Memcache extension First, you need to install Me in your PHP environment

In Java programming, the add operation is a common and important operation used to add elements to a data structure. In this article, we will take an in-depth look at the principles and usage of the add operation in Java, and give specific code examples to help readers better understand. The add operation is usually used to add elements to collection type data structures, such as ArrayList, LinkedList, etc. These data structures all implement the List interface in Java, which provides the add method for adding elements. I
