- 浏览: 2552014 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
AMAZON ElastiCache(1)Redis Basic Operation and Testing
We are using AMAZON Server which is not Redis 3.0 yet, the latest is 2.8.x. So it is not really Redis Cluster, it is master and slave. And we can only balance the read operation on the slaves.
Finally, my colleague who is a really smart people find one scala driver for me.
build.sbt
"com.etaty.rediscala" %% "rediscala" % "1.4.2”, //scala drvier
"com.orange.redis-embedded" % "embedded-redis" % "0.6" % “test” //embedded server
And there is only one RedisElastiCache.scala core implementation
package com.sillycat.jobsconsumer.persistence
import akka.actor.ActorSystem
import akka.util.ByteString
import com.sillycat.jobsconsumer.utilities.{IncludeConfig, IncludeLogger}
import redis.{RedisClientMasterSlaves, RedisServer}
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.collection.JavaConverters._
object RedisElastiCache extends IncludeLogger with IncludeConfig{
implicit var actorSystem: ActorSystem = _
private val cachePool = {
try {
logger.info("Init the Akka System.")
actorSystem = ActorSystem("RedisScalaClients")
val masterHost = config.getString(envStr("redis.master"))
logger.info("Connect to master host = " + masterHost)
val master = RedisServer(masterHost)
val slaves = config.getStringList(envStr("redis.slaves")).asScala map { case slaveHost: String =>
logger.info("Connect to slave host = " + slaveHost)
RedisServer(slaveHost)
}
RedisClientMasterSlaves(master,slaves.toSeq)
} catch {
case x: Throwable =>
logger.error("Couldn't connect to ElastiCache: " + x)
null
}
}
def releaseResource = {
if(actorSystem != null){
actorSystem.shutdown()
}
}
def get(key: String):Option[Any] = {
val future = cachePool.get(key)
future onFailure {
case e => {
logger.error("Fetch to fetch the value from ElastiCache: " + e.getMessage)
}
}
Await.result(future, 5 seconds) match {
case Some(v:ByteString) => {
logger.debug("Receiving the result from remote: " + new String(v.toArray))
Some(new String(v.toArray))
}
case _ => {
logger.error("Get Wrong format from ElastiCache.")
None
}
}
}
def put(key:String, value:Any) = {
val future = cachePool.set(key, value.toString)
future onFailure {
case e => logger.error("Fetch to put the value to ElastiCache: " + e.getMessage)
}
Await.result(future, 5 seconds)
}
}
Here is the test class RedisElastiCacheSpec.scala
package com.sillycat.jobsconsumer.persistence
import com.sillycat.jobsconsumer.utilities.IncludeConfig
import org.scalatest.{Matchers, FunSpec}
import org.scalatest.BeforeAndAfterAll
import redis.embedded.RedisServer
/**
* Created by carl on 7/31/15.
*/
class RedisElastiCacheSpec extends FunSpec with Matchers with BeforeAndAfterAll with IncludeConfig{
var redisEmbeded :RedisServer = _
override def beforeAll() {
if(config.getString("build.env").equals("test")){
redisEmbeded = new RedisServer(6379)
redisEmbeded.start()
}
}
override def afterAll() {
RedisElastiCache.releaseResource
if(redisEmbeded != null){
redisEmbeded.stop()
}
}
describe("RedisElastiCache") {
describe("#put & get"){
it("Put String to ElastiCache") {
val expect = "<job>sdfasdf</job>"
RedisElastiCache.put("key1",expect)
val result = RedisElastiCache.get("key1")
result should be (Some(expect))
}
}
}
}
References:
http://maciejb.me/2012/10/17/testing-your-java-amazon-sqs-code-with-elasticmq/
https://github.com/kstyrc/embedded-redis
http://msgpack.org/
http://alvinalexander.com/scala/serializing-deserializing-xml-scala-classes
https://github.com/xetorthio/jedis
master and slave
http://etaty.github.io/rediscala/latest/api/index.html#redis.RedisClientMasterSlaves
https://github.com/debop/debop4s/blob/36ab5a45181e03022d5b219ac0dec5bcaed714b6/debop4s-rediscala/src/test/scala/debop4s/rediscala/client/MasterSlavesFunSuite.scala
embeded server for testing
https://github.com/kstyrc/embedded-redis
We are using AMAZON Server which is not Redis 3.0 yet, the latest is 2.8.x. So it is not really Redis Cluster, it is master and slave. And we can only balance the read operation on the slaves.
Finally, my colleague who is a really smart people find one scala driver for me.
build.sbt
"com.etaty.rediscala" %% "rediscala" % "1.4.2”, //scala drvier
"com.orange.redis-embedded" % "embedded-redis" % "0.6" % “test” //embedded server
And there is only one RedisElastiCache.scala core implementation
package com.sillycat.jobsconsumer.persistence
import akka.actor.ActorSystem
import akka.util.ByteString
import com.sillycat.jobsconsumer.utilities.{IncludeConfig, IncludeLogger}
import redis.{RedisClientMasterSlaves, RedisServer}
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.collection.JavaConverters._
object RedisElastiCache extends IncludeLogger with IncludeConfig{
implicit var actorSystem: ActorSystem = _
private val cachePool = {
try {
logger.info("Init the Akka System.")
actorSystem = ActorSystem("RedisScalaClients")
val masterHost = config.getString(envStr("redis.master"))
logger.info("Connect to master host = " + masterHost)
val master = RedisServer(masterHost)
val slaves = config.getStringList(envStr("redis.slaves")).asScala map { case slaveHost: String =>
logger.info("Connect to slave host = " + slaveHost)
RedisServer(slaveHost)
}
RedisClientMasterSlaves(master,slaves.toSeq)
} catch {
case x: Throwable =>
logger.error("Couldn't connect to ElastiCache: " + x)
null
}
}
def releaseResource = {
if(actorSystem != null){
actorSystem.shutdown()
}
}
def get(key: String):Option[Any] = {
val future = cachePool.get(key)
future onFailure {
case e => {
logger.error("Fetch to fetch the value from ElastiCache: " + e.getMessage)
}
}
Await.result(future, 5 seconds) match {
case Some(v:ByteString) => {
logger.debug("Receiving the result from remote: " + new String(v.toArray))
Some(new String(v.toArray))
}
case _ => {
logger.error("Get Wrong format from ElastiCache.")
None
}
}
}
def put(key:String, value:Any) = {
val future = cachePool.set(key, value.toString)
future onFailure {
case e => logger.error("Fetch to put the value to ElastiCache: " + e.getMessage)
}
Await.result(future, 5 seconds)
}
}
Here is the test class RedisElastiCacheSpec.scala
package com.sillycat.jobsconsumer.persistence
import com.sillycat.jobsconsumer.utilities.IncludeConfig
import org.scalatest.{Matchers, FunSpec}
import org.scalatest.BeforeAndAfterAll
import redis.embedded.RedisServer
/**
* Created by carl on 7/31/15.
*/
class RedisElastiCacheSpec extends FunSpec with Matchers with BeforeAndAfterAll with IncludeConfig{
var redisEmbeded :RedisServer = _
override def beforeAll() {
if(config.getString("build.env").equals("test")){
redisEmbeded = new RedisServer(6379)
redisEmbeded.start()
}
}
override def afterAll() {
RedisElastiCache.releaseResource
if(redisEmbeded != null){
redisEmbeded.stop()
}
}
describe("RedisElastiCache") {
describe("#put & get"){
it("Put String to ElastiCache") {
val expect = "<job>sdfasdf</job>"
RedisElastiCache.put("key1",expect)
val result = RedisElastiCache.get("key1")
result should be (Some(expect))
}
}
}
}
References:
http://maciejb.me/2012/10/17/testing-your-java-amazon-sqs-code-with-elasticmq/
https://github.com/kstyrc/embedded-redis
http://msgpack.org/
http://alvinalexander.com/scala/serializing-deserializing-xml-scala-classes
https://github.com/xetorthio/jedis
master and slave
http://etaty.github.io/rediscala/latest/api/index.html#redis.RedisClientMasterSlaves
https://github.com/debop/debop4s/blob/36ab5a45181e03022d5b219ac0dec5bcaed714b6/debop4s-rediscala/src/test/scala/debop4s/rediscala/client/MasterSlavesFunSuite.scala
embeded server for testing
https://github.com/kstyrc/embedded-redis
发表评论
-
Stop Update Here
2020-04-28 09:00 316I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 476NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 369Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 370Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 455VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 478NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 423Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 248GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 451GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 312Serverless with NodeJS and Tenc ...
相关推荐
elasticache-chatapp构建集成 Amazon ElastiCache for Redis 的基于 Web 的聊天应用程序的示例架构。ElastiCache 聊天应用程序(见下图)演示了如何在前端使用 Vue.js 和 Socket.io 构建 Web 聊天客户端,以便使用 ...
Amazon ElastiCache 示例使用与Redis OSS 兼容的Amazon ElastiCache和Memcached的示例和文档。博客在线特征存储使用兼容 Redis OSS 的 Amazon ElastiCache 在 AWS 上构建在线特征存储,以支持需要超低延迟和高吞吐量...
terraform-aws-elasticache-redis Terraform模块以配置 Redis集群该项目是我们针对DevOps的全面方法的一部分。 它是100%开源的,并根据许可。 从字面上看,我们有,它们都是开源的并且维护良好。 去看一下!安全与...
弹性的chatapp 用于构建集成了Amazon ElastiCache for Redis的基于Web的聊天应用程序的示例架构。 ElastiCache聊天应用程序(见下图)演示了如何在前端使用Vue.js和Socket.io构建Web聊天客户端,以使用Node.js,...
1. **集群大小**:定义Redis集群的节点数量,包括主节点和副本节点。 2. **安全组**:配置访问ElastiCache集群的安全规则,如入站和出站端口,以及允许的IP范围。 3. **参数组**:设置Redis实例的参数,如内存限制、...
从 AWS Elasticache (Redis) 获取数据库转储并将其复制到 AWS S3 这里我们使用 [Terraform] ( ) 来进行自动化。 #要求 安装 Terraform 您需要提供以下值 AWS ACCESS KEY AWS SECRET KEY AWS REGION AWS ...
Terraform-aws-elasticache-redis用于创建 AWS Redis ElastiCache 集群的 Terraform 模块Terraform 版本对于 AWS 提供商 >= 4.0.0,将模块版本固定至~> v3.0。对于 Terraform 0.14.5 及更高版本和AWS Provider ,将...
Terraform 模块用于配置ElastiCacheRedis 集群或无服务器实例。提示 将 Atmos 与 Terraform 结合使用Cloud Posseatmos使用 Terraform 轻松协调多个环境。可与Github Actions、Atlantis或Spacelift配合使用。观看使用...
aws-node-elasticache-vpc 一组在VPC中使用Elasticache(redis)的无服务器功能入门为了安装和运行此示例,您需要使用系统配置的AWS账户凭证。 要开始使用AWS账户配置,请点击此克隆aws-node-elasticache-vpc并安装...
RDM supports SSL/TLS encryption, SSH tunnels, TLS over SSH tunnel (AWS ElastiCache with In-Transit Encryption) and cloud Redis instances such as: Amazon ElastiCache, Microsoft Azure Redis Cache and ...
redis desktop manager(redisdesktop...rdm支持ssl/tls加密,ssh隧道,基于ssh隧道的tls(带有in-transit加密的aws elasticache)和云redis实例,例如:amazon elasticache,microsoft azure redis cache和redis labs。
Redis桌面管理器(又名RDM) -是一个快速开放源码的...RDM支持SSL/TLS加密、SSH隧道、SSH隧道之上的TLS (AWS ElastiCache支持传输加密)和云Redis实例,如:Amazon ElastiCache、Microsoft Azure Redis Cache和Redis Labs。
Redis桌面管理器(又名RDM) - 是一...RDM支持SSL / TLS加密,SSH隧道,基于SSH隧道的TLS(带有In-Transit加密的AWS ElastiCache)和云Redis实例,例如:Amazon ElastiCache,Microsoft Azure Redis Cache和Redis Labs
Redis桌面管理器(又名RDM) - 是一...RDM支持SSL / TLS加密,SSH隧道,基于SSH隧道的TLS(带有In-Transit加密的AWS ElastiCache)和云Redis实例,例如:Amazon ElastiCache,Microsoft Azure Redis Cache和Redis Labs
Redis Desktop Manager (aka RDM) — is a fast open source ...RDM supports SSL/TLS encryption, SSH tunnels and cloud Redis instances such as: Amazon ElastiCache, Microsoft Azure Redis Cache and Redis Labs.
如将键视为树,CRUD键,通过shell执行命令等,并且Redis Desktop Manager支持SSL / TLS加密,SSH隧道,基于SSH隧道的TLS(带有In-Transit加密的AWS ElastiCache)和云Redis实例,例如:Amazon ElastiCache,...
Redis Desktop Manager 是一个可视化...RDM支持SSL / TLS加密,SSH隧道,基于SSH隧道的TLS(带有In-Transit加密的AWS ElastiCache)和云Redis实例,例如:Amazon ElastiCache,Microsoft Azure Redis Cache和Redis Labs
RedisDesktopManager 2020.4.104 mac 最新版本。Redis桌面管理器(又名RDM) -是一个可以应用于Windows, Linux...RDM支持SSL/TLS加密,SSH隧道和云Redis实例,如:Amazon ElastiCache,微软Azure Redis缓存和Redis实验室。
可以与 Amazon ElastiCache,Microsoft Azure Redis Cache 和 Redis Labs 等服一起使用。使用 RDM 分析您的Redis服务器内存使用情况,并通过批量删除来删除过期的数据。RDM支持 TLS,SSH 和 TLS-over-SSH 隧道,可...
RedisDesktopManager 是 Redis桌面...RDM支持SSL / TLS加密,SSH隧道,基于SSH隧道的TLS(带有In-Transit加密的AWS ElastiCache)和云Redis实例,例如:Amazon ElastiCache,Microsoft Azure Redis Cache和Redis Labs