当前位置: 首页 > news >正文

网站推广营销的意义会ps的如何做网站

网站推广营销的意义,会ps的如何做网站,新公司做网站怎么做,2019wordpress使用手册Memcached是一个开源、高性能,将数据分布于内存中并使用key-value存储结构的缓存系统。它通过在内存中缓存数据来减少向数据库的频繁访问连接的次数,可以提高动态、数据库驱动之类网站的运行速度。 Memcached在使用是比较简单的,在操作上基本…

Memcached是一个开源、高性能,将数据分布于内存中并使用key-value存储结构的缓存系统。它通过在内存中缓存数据来减少向数据库的频繁访问连接的次数,可以提高动态、数据库驱动之类网站的运行速度。

Memcached在使用是比较简单的,在操作上基本就类似于操作字典结构的对象一样

1 添加依赖

这里需要添加上web、swagger和spymemcached的依赖,Swagger是为了方便接口测试。

对于spymemcached的支持,其实只要如下这个依赖包就可以了。

<!-- https://mvnrepository.com/artifact/net.spy/spymemcached -->
<dependency><groupId>net.spy</groupId><artifactId>spymemcached</artifactId><version>2.12.3</version>
</dependency>

2 添加相关配置

2.1 添加swagger 配置

添加一个swagger 配置类,在工程下新建 config 包并添加一个 SwaggerConfig 配置类,除了常规配置外,加了一个令牌属性,可以在接口调用的时候传递令牌。

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;@Configuration
@EnableSwagger2
public class SwaggerConfig {@Beanpublic Docket createRestApi(){return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build();}private ApiInfo apiInfo(){return new ApiInfoBuilder().title("Swagger API Doc").description("This is a restful api document of Swagger.").version("1.0").build();}}
2.2.在配置文件添加memcache的主机端口信息

application.properties

memcache.ip=127.0.0.1
memcache.port=11211

application.yml

memcache:ip: 127.0.0.1port: 11211
2.3.添加一个MemcacheConfig配置类,读取主机端口并构造一个MemcachedClient。

MemcacheConfig.java

import java.io.IOException;
import java.net.InetSocketAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import net.spy.memcached.MemcachedClient;@Configuration
public class MemcacheConfig {@Value("${memcache.ip}")private String ip;@Value("${memcache.port}")private int port;@Beanpublic MemcachedClient getClient() {MemcachedClient memcachedClient = null;try {memcachedClient  = new MemcachedClient(new InetSocketAddress(ip, port));} catch (IOException e) {e.printStackTrace();}return memcachedClient;}
}
2.4 编写业务接口

编写一个业务控制器,通过MemcachedClient实现对缓存的设置和读取。

MemcacheController.java

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.internal.OperationFuture;@RestController
public class MemcacheController {private Logger logger = LoggerFactory.getLogger(getClass());@Autowiredprivate MemcachedClient memcachedClient;@GetMapping("/info")public String memcacheGetValue() throws InterruptedException {// 取出缓存Object value = memcachedClient.get("userName");logger.info("取出缓存 "+value);return "取出的值  "+value;}@GetMapping("/save")public String saveValue(@RequestParam String userName) throws InterruptedException {// 放入缓存, 过期时间为5000,单位为毫秒OperationFuture<Boolean> flag = memcachedClient.set("userName", 5000, userName);return "保存成功";}
}

3 编译运行测试

3.1. 右键项目 -> Run as -> Maven install,开始执行Maven构建,第一次会下载Maven依赖,可能需要点时间

在这里插入图片描述

3.2. 右键文件 DemoApplication.java -> Run as -> Java Application,开始启动应用

在这里插入图片描述

3.3. 打开浏览器,访问:http://localhost:8899/swagger-ui.html,进入swagger接口文档界面。

这里的端口根据具体的项目启动来查看,我这里是 8899
在这里插入图片描述

http://www.yayakq.cn/news/239079/

相关文章:

  • 如何下载别人的网站做模板华为公司网站建设目标
  • 网站站点风格汽车网站开发毕业设计论文
  • php网站开发模式有哪些潍坊网站建设哪家专业
  • 网站建设页面页脚怎么设置app模拟制作
  • 专门做网站的公司 南阳抖音小程序入口在哪里
  • 怎么用目录建wordpress站点建行app官方下载
  • 公司网站怎么注销推广拉新任务的平台
  • 厦门高端网站建设网站互动营销
  • 有没有网页设计专业网站建设推广优化岗位说明书
  • 门户网站的类型谷歌商店下载安装
  • 如何在网站上做评比做网站需要的东西
  • 宠物社区网站开发设计文档网络网站公司
  • 韩国优秀网站设计东莞网站开发公司哪家好
  • 做旅游网站的yi个人建什么网站最赚钱吗
  • 做网站需要什么权限wordpress标签归档
  • 产品 网站建设汉川网站开发
  • 烟台网站制作山海云女朋友做网站
  • 重庆市网站建设公司优化推广什么意思
  • 网站标题会影响吗营销型网站建设是什么
  • 孔夫子旧书网网站谁做的湛江搭建做网站在哪里做
  • 中文儿童网站模板wordpress now 1.5
  • 公司做外地网站滁州新手跨境电商建站哪家好
  • 域名和网站空间怎么做解析网络营销论文任务书
  • 东莞学校网站建设网站建设 岗位
  • 石家庄市住房和建设局网站crm销售
  • 模板网站合同网页设计友情链接怎么做
  • 怎样设置网站桂林两江四湖景区怎么游览
  • 专门做网站的软件多少钱网站设计
  • 建设官方网站需要注意什么网站开发我嵌入式开发
  • 嘉定房产网站建设湛江网站定制