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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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/)

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

How to use Memcache for efficient data writing and querying in PHP development? With the continuous development of Internet applications, the requirements for system performance are getting higher and higher. In PHP development, in order to improve system performance and response speed, we often use various caching technologies. One of the commonly used caching technologies is Memcache. Memcache is a high-performance distributed memory object caching system that can be used to cache database query results, page fragments, session data, etc. By storing data in memory

The practice and thinking of Memcache caching technology to optimize data interaction in PHP In modern Web applications, data interaction is a very important issue. It is not efficient enough and will limit the scalability and performance of Web applications. In order to speed up data interaction, our usual approach is to optimize the design of the database, improve the performance of the hardware and increase the server capacity. However, these methods all have a common limitation: they increase the cost of the system. In recent years, Memcache technology has made progress in solving this problem.

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,

Memcache is an open source, distributed caching technology. It greatly improves the speed of data access by storing data in memory, thus improving the performance and responsiveness of the website. In PHP projects, Memcache caching technology is also widely used and has achieved good results. This article will deeply explore the application and practice of Memcache caching technology in PHP projects. 1. Principles and advantages of Memcache Memcache is a memory caching technology that can store data

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
