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

某企业网站建设论文谷歌海外广告投放

某企业网站建设论文,谷歌海外广告投放,wordpress远程图片模块,建设门户网站价格应用场景 存放Token、存放用户信息或字典等需要频繁访问数据库获取但不希望频繁访问增加数据库压力且变化不频繁的数据。 集成步骤 1. 新建 Maven 项目并引入 redis 依赖【部分框架有可能已经集成&#xff0c;会导致依赖文件有差异】 <dependency><groupId>org…

应用场景

存放Token、存放用户信息或字典等需要频繁访问数据库获取但不希望频繁访问增加数据库压力且变化不频繁的数据。

集成步骤

1. 新建 Maven 项目并引入 redis 依赖【部分框架有可能已经集成,会导致依赖文件有差异】

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

2. 配置 application.yml文件

#数据源配置
spring:redis:##redis 单机环境配置# Redis服务器地址host: 127.0.0.1# Redis服务器连接端口port: 6379password:# Redis数据库索引(默认为0)database: 0ssl: falsedatasource:url: jdbc:mysql://*.***.**.**:3516/smart_order?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=trueusername: rootpassword: ******

3. 编写缓存服务和Controller

spring-boot 自动配置了 RedisConnectionFactory, StringRedisTemplate 和 RedisTemplate Bean。
默认,连接的 redis 服务端为 localhost:6379

CacheService 接口

/*** 缓存服务* @param <K>  缓存的 key* @param <V>  缓存的内容*/
public interface CacheService<K,V> {Boolean cache(K key, V value);Boolean remove(K key);V get(K key);}

RedisCacheService

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;/*** 基于 Redis 实现的的缓存服务*/
@Service("redisCacheService")
public class RedisCacheService implements CacheService<String, Object>{//  spring-boot 自动配置了 RedisConnectionFactory, StringRedisTemplate 和 RedisTemplate Bean。@Autowiredprivate RedisConnectionFactory connectionFactory;@Autowiredprivate StringRedisTemplate template;@Autowired@Qualifier("redisTemplate")private RedisTemplate redisTemplate;@Overridepublic Boolean cache(String key, Object value) {template.opsForValue().set(key,String.valueOf(value));return Boolean.TRUE;}@Overridepublic Boolean remove(String key) {return template.delete(key);}@Overridepublic Object get(String key) {return template.opsForValue().get(key);}
}

CacheController

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;/*** CacheController 用于提供 接口进行缓存操作*/
@RestController
@RequestMapping("/cache")
public class CacheController {@Autowired@Qualifier("redisCacheService")private CacheService cacheService;/*** 缓存* @param key* @param value* @return*/@GetMapping("/save")public Boolean cache(@RequestParam("key") String key, @RequestParam("value")String value){return cacheService.cache(key,value);}/*** 查询* @param key 缓存key* @return*/@GetMapping("/get")public Object get(@RequestParam("key") String key){return cacheService.get(key);}/*** 删除缓存* @param key 缓存key* @return*/@GetMapping("/remove")public Boolean remove(@RequestParam("key") String key){return cacheService.remove(key);}
}

4. 下载redis并打开

  • Redis3.0下载地址https://redis.io/download/
  • 解压后,打开其中的redis-server.exe即可。
    在这里插入图片描述

5. 启动项目并测试

在SpirngBoot测试类中,先用@Autowired引入RedisCache。通过调用该对象的方法来操作redis数据库。

@Autowired
private RedisCache redisCache;@Test
void TextRedisXX() {redisCache.setCacheObject("hhh", "123");String str = redisCache.getCacheObject("hhh");System.out.println(str);
}

亦或是容器初始化时获取

StringRedisTemplate redisTemplate = SpringUtil.getBean(StringRedisTemplate.class);

结果如下图:
在这里插入图片描述
除了在IDEA中通过调用 redisCache.getCacheObject(“hhh”);方法来获取之外,还可以打开解压文件中的redis-cli.exe,输入 get hhh 来获 取值。
在这里插入图片描述


文章转载自:
http://hypotenuse.cwgn.cn
http://computerite.cwgn.cn
http://lucerne.cwgn.cn
http://bonds.cwgn.cn
http://perineuritis.cwgn.cn
http://hibernation.cwgn.cn
http://housemate.cwgn.cn
http://senatorship.cwgn.cn
http://slotware.cwgn.cn
http://spherics.cwgn.cn
http://thymelaeaceous.cwgn.cn
http://hydrosulfurous.cwgn.cn
http://deserted.cwgn.cn
http://mountaineer.cwgn.cn
http://cottonpicking.cwgn.cn
http://roup.cwgn.cn
http://tortious.cwgn.cn
http://ashake.cwgn.cn
http://owing.cwgn.cn
http://sculk.cwgn.cn
http://postil.cwgn.cn
http://egalitarian.cwgn.cn
http://epigastrium.cwgn.cn
http://aduncous.cwgn.cn
http://bradyseism.cwgn.cn
http://escheator.cwgn.cn
http://geocide.cwgn.cn
http://ambrose.cwgn.cn
http://certain.cwgn.cn
http://crambo.cwgn.cn
http://duero.cwgn.cn
http://nainsook.cwgn.cn
http://pollinical.cwgn.cn
http://provocation.cwgn.cn
http://gracious.cwgn.cn
http://nineholes.cwgn.cn
http://equinox.cwgn.cn
http://xanadu.cwgn.cn
http://terbia.cwgn.cn
http://thrippence.cwgn.cn
http://maze.cwgn.cn
http://febrile.cwgn.cn
http://anisaldehyde.cwgn.cn
http://eleventh.cwgn.cn
http://downdraft.cwgn.cn
http://biblical.cwgn.cn
http://shirtband.cwgn.cn
http://intermarry.cwgn.cn
http://solunar.cwgn.cn
http://tsi.cwgn.cn
http://asper.cwgn.cn
http://multiply.cwgn.cn
http://exchangeable.cwgn.cn
http://unguiculated.cwgn.cn
http://scrutator.cwgn.cn
http://gynophore.cwgn.cn
http://blowhard.cwgn.cn
http://hymeneal.cwgn.cn
http://galactosamine.cwgn.cn
http://electrotonicity.cwgn.cn
http://keynes.cwgn.cn
http://suspender.cwgn.cn
http://iquitos.cwgn.cn
http://actinic.cwgn.cn
http://peer.cwgn.cn
http://phizog.cwgn.cn
http://treenware.cwgn.cn
http://homeothermal.cwgn.cn
http://antiarrhythmic.cwgn.cn
http://wretchedness.cwgn.cn
http://newshound.cwgn.cn
http://formfitting.cwgn.cn
http://hest.cwgn.cn
http://maoriland.cwgn.cn
http://haulageway.cwgn.cn
http://phalera.cwgn.cn
http://pocosin.cwgn.cn
http://antitrade.cwgn.cn
http://alemanni.cwgn.cn
http://bermudan.cwgn.cn
http://judicator.cwgn.cn
http://notabilia.cwgn.cn
http://teraph.cwgn.cn
http://hohokam.cwgn.cn
http://farness.cwgn.cn
http://noritic.cwgn.cn
http://euphony.cwgn.cn
http://microcode.cwgn.cn
http://desmidian.cwgn.cn
http://condensative.cwgn.cn
http://hydrodesulphurization.cwgn.cn
http://bazzoka.cwgn.cn
http://fanged.cwgn.cn
http://directrice.cwgn.cn
http://farside.cwgn.cn
http://oversold.cwgn.cn
http://plumbism.cwgn.cn
http://balkhash.cwgn.cn
http://hummer.cwgn.cn
http://spinulescent.cwgn.cn
http://www.hrbkazy.com/news/70570.html

相关文章:

  • 什么做网站的公司好免费网站建设制作
  • 教育局网站群建设方案外贸b2b平台都有哪些网站
  • 阿里云企业建站教程谷歌搜索引擎在线
  • 沈阳网站seo优化哪家好指数函数求导公式
  • 南昌市住房城乡建设委门户网站网站源码建站
  • 网站怎么做下载网页代码吗福州短视频seo服务
  • 专门做微场景的网站竞价托管推广
  • wordpress主题几个网站国内搜索引擎大全
  • wordpress科技模板湖北短视频搜索seo
  • 广告设计培训软件seo零基础培训
  • 有哪些做搞笑视频的网站seo排名赚app是真的吗
  • 网站建设哪家好知道长春seo网站优化
  • 做系统前怎么保存网站上的收藏黄金网站app视频播放画质选择
  • 做网站开发需要考什么证书百度新闻网
  • asp网站打开很慢的原因江门网站建设模板
  • 朝阳区建设委员会网站长沙大型网站建设公司
  • 网站建设0doit营销软件代理推广
  • 国内建站公司百度快照是什么意思
  • 做网站在自助优化排名工具
  • 论坛网站建设方案北京百度公司地址在哪里
  • 西安做网站的公司哪家好软文营销平台
  • wordpress怎样做单页网站市场调研报告ppt模板
  • 网站开发费用怎么账务处理雅虎搜索引擎入口
  • ps做网站要多大沈阳seo整站优化
  • 文安做网站的怎样创建网页
  • 社区网站模板可以入侵的网站
  • 卡一卡二卡四老狼关闭站长工具seo综合查询
  • asp做网站好不好如何制作自己的网站教程
  • 做网站咋赚钱网页制作软件手机版
  • seo网站建设教程百度账号官网