Home >Backend Development >PHP Tutorial >Implementation code for operating memcached cache in php to add, delete, modify and check data, phpmemcached_PHP tutorial
Core code:
<?php //创建一个memcache对象实例 $memcache = new Memcache; if(!$memcache->connect("127.0.0.1",11211)){ die('连接失败'); } if($memcache->set('key1',"xian",MEMCACHE_COMPRESSED,60)){ echo 'sucess!'; }//存值,其中xian字符串,也可以为数组,对象,但不能为资源 $val = $memcache->get('key1');//查询获取值 echo $val; $memcache->replace('key1','beijing',MEMCACHE_COMPRESSED,60);//修改 $memcache->delete('key1');//删除 ?>
Hey, isn’t this just a small background operation?
Give me an idea: make a table, use a foreach loop to print out the table information at once, and present it in the table. Write edit and delete in the last two TDs of the table. As for adding, you need to Open a single page, pass the id when editing, take out all the values of the id at once and pay the relevant value. Deletion is easier. Delete the row of data in the table according to the passed id
As for uploading pictures , then it needs to be encapsulated into the image processing library. You only need to pass the image name and perform related operations through the $_FILES global variable, such as determining the suffix and size of the uploaded file and the information presented to the customer after the upload fails.
It looks so messy!