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

滨江区建设局官方网站wordpress迁移hexo

滨江区建设局官方网站,wordpress迁移hexo,广告公司活动策划公司,不会写代码怎么做网站Memcached是一个开源、高性能#xff0c;将数据分布于内存中并使用key-value存储结构的缓存系统。它通过在内存中缓存数据来减少向数据库的频繁访问连接的次数#xff0c;可以提高动态、数据库驱动之类网站的运行速度。 Memcached在使用是比较简单的#xff0c;在操作上基本…Memcached是一个开源、高性能将数据分布于内存中并使用key-value存储结构的缓存系统。它通过在内存中缓存数据来减少向数据库的频繁访问连接的次数可以提高动态、数据库驱动之类网站的运行速度。 Memcached在使用是比较简单的在操作上基本就类似于操作字典结构的对象一样 1 添加依赖 这里需要添加上web、swagger和spymemcached的依赖Swagger是为了方便接口测试。 对于spymemcached的支持其实只要如下这个依赖包就可以了。 !-- https://mvnrepository.com/artifact/net.spy/spymemcached -- dependencygroupIdnet.spy/groupIdartifactIdspymemcached/artifactIdversion2.12.3/version /dependency2 添加相关配置 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.ip127.0.0.1 memcache.port11211application.yml memcache:ip: 127.0.0.1port: 112112.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单位为毫秒OperationFutureBoolean 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.dnsts.com.cn/news/158262.html

相关文章:

  • 网站优化软件排名技术亚马逊跨境电商个人开店要多少钱
  • 网站设计制作厂家有哪些网站建设不能在淘宝发布
  • 章丘网站建设公司php网站的数据库在哪
  • 手机网站支持微信支付吗南京小程序定制开发
  • 网站建设摘要那些做环保网站的好
  • 网站建设与企业发展特效视频素材网站
  • 营销型网站如何策划可以制作动画的软件
  • 制作淘宝网页网站WordPress小工具可以做什么
  • 域名网站建设方案书苏州百度代理公司
  • 泗县建设银行网站dedecms网站上传服务器不是空间
  • 5118网站查询嘉兴设计公司有哪些
  • 华为开发平台seo排名软件怎么做
  • 信创网站建设技术成果交易网站建设方案
  • 如何增加网站外链公司制作网站多少钱
  • 有没有做网站源代码修改的郑州平台公司
  • 江苏网站建设哪家专业百科网站怎么做
  • 齐河网站建设价格营销型网站建设合同模板
  • 门户网站建设汇报材料班级网站怎么做ppt模板
  • 如何自己做网站手机软件免费网站制作效果
  • 淘宝客网站虚拟主机西安市建设工程信息网诚信平台
  • 简约风格网站设计纯文字logo在线制作
  • 网站开发 制作阶段的说课稿微信内部劵网站怎么做
  • 网上祭奠类网站怎么做站长推广工具
  • 做网站开发需要的英语水平做视频网站需要什么条件
  • 专业的网站建设宝安西乡合肥网站制作建设公司
  • 安徽省建设工程信息网官网是什么网站岳阳seo官网
  • 张家港专业的网站制作公司中国500强最新排名2021
  • 中企做网站超市网站建设方案
  • 深圳建网站的公辽宁省建设工程信息网业绩公示
  • 交流建筑的网站网页设计导航栏素材