lua

Install resty.http with already installed openresty

一笑奈何 提交于 2021-01-04 07:27:08
问题 I installed openresty-1.13.6.1 but it lacks 'resty.http' module. My openresty is installed in /usr/local/openresty and i need to integrate resty.http module with it. How to do it? 回答1: Just copy both files (https://github.com/pintsized/lua-resty-http/tree/master/lib/resty) into /usr/local/openresty/lualib folder. Update: Resulted file structure should be: /usr/local/openresty/lualib/resty/http.lua /usr/local/openresty/lualib/resty/http_headers.lua 来源: https://stackoverflow.com/questions

加强版Redis,又一款国产高性能KV存储数据库开源了!

杀马特。学长 韩版系。学妹 提交于 2021-01-03 11:00:12
项目简介 Tendis是腾讯互娱CROS DBA团队 & 腾讯云数据库团队自主设计和研发的分布式高性能KV存储数据库,兼容Redis核心数据结构与接口。 可提供大容量、低成本、强持久化的数据库能力,适用于兼容Redis协议、需要大容量且较高访问性能的温冷数据存储场景。 Tendis目前已经被应用到腾讯内、外部大型项目中。 集群架构 Tendis使用去中心化集群架构,每个数据节点都拥有全部的路由信息,用户可以访问集群中的任意节点,并且通过redis的move协议,最终路由到正确的节点。 每个Tendis节点维护各自的slot数据,任意两个master节点之间的slot不重复,master节点之间支持基于slot的数据搬迁,主备节点之间通过binlog实现数据复制。 所有节点之间通过gossip协议进行通讯,类似于redis cluster的分布式实现,所有节点通过gossip协议通讯,可指定hashtag来控制数据分布和访问,使用和运维成本极低。 适用场景 兼容Redis协议,需要大容量且较高访问性能的温冷数据存储场景 适合成本为主要考虑因素,业务数据有高持久化要求的业务场景 解决原生Redis固有的fork问题而预留部分内存问题 主要特性 兼容Redis协议 完全兼容redis协议,支持redis主要数据结构和接口,兼容大部分原生Redis命令。 持久化存储

Lua - Delete non-empty directory

柔情痞子 提交于 2021-01-03 06:55:51
问题 I'm trying to remove non-empty directory in Lua but without success, I tried the following: os.remove(path_to_dir) And got the error: Directory not empty 39 When 39 is the number of files in path_to_dir Also tried: require ('lfs') lfs.rmdir(path_to_dir) And got the error: Directory not empty' Worth to mention that I did chmod -R a+rX * to path_to_dir Thanks for the help. 回答1: You can either follow @EgorSkriptunoff's suggestion and use OS-specific commands to remove non-empty directories or

Lua - Delete non-empty directory

若如初见. 提交于 2021-01-03 06:55:37
问题 I'm trying to remove non-empty directory in Lua but without success, I tried the following: os.remove(path_to_dir) And got the error: Directory not empty 39 When 39 is the number of files in path_to_dir Also tried: require ('lfs') lfs.rmdir(path_to_dir) And got the error: Directory not empty' Worth to mention that I did chmod -R a+rX * to path_to_dir Thanks for the help. 回答1: You can either follow @EgorSkriptunoff's suggestion and use OS-specific commands to remove non-empty directories or

Using a coordinate pair as a key in a Lua table

怎甘沉沦 提交于 2021-01-03 06:29:07
问题 As the title says, I'm trying to use a coordinate pair (x, y) as a key for a table. Here is what I have done so far local test = {_props = {}} local mt = {} local xMax = 5 local yMax = 5 local function coord2index(x, y) return ((x-1) * xMax) + y end mt.__index = function(s, k) if s._props[coord2index(k[1], k[2])] ~= nil then return s._props[coord2index(k[1], k[2])] end end mt.__newindex = function(s, k, v) s._props[coord2index(k[1], k[2])] = v end mt.__call = function (t, k) if type(k) ==

Using a coordinate pair as a key in a Lua table

旧城冷巷雨未停 提交于 2021-01-03 06:28:20
问题 As the title says, I'm trying to use a coordinate pair (x, y) as a key for a table. Here is what I have done so far local test = {_props = {}} local mt = {} local xMax = 5 local yMax = 5 local function coord2index(x, y) return ((x-1) * xMax) + y end mt.__index = function(s, k) if s._props[coord2index(k[1], k[2])] ~= nil then return s._props[coord2index(k[1], k[2])] end end mt.__newindex = function(s, k, v) s._props[coord2index(k[1], k[2])] = v end mt.__call = function (t, k) if type(k) ==

P0级重大事故:超卖了100瓶飞天茅台,整个项目组慌得一逼~

倖福魔咒の 提交于 2021-01-01 03:08:25
前言 基于Redis使用分布式锁在当今已经不是什么新鲜事了。本篇文章主要是基于我们实际项目中因为redis分布式锁造成的事故分析及解决方案。 背景 : 我们项目中的抢购订单采用的是分布式锁来解决的。有一次,运营做了一个飞天茅台的抢购活动,库存100瓶,但是却超卖了!要知道,这个地球上飞天茅台的稀缺性啊!!!事故定为P0级重大事故...只能坦然接受。整个项目组被扣绩效了~~事故发生后,CTO指名点姓让我带头冲锋来处理,好吧,冲~ 事故现场 经过一番了解后,得知这个抢购活动接口以前从来没有出现过这种情况,但是这次为什么会超卖呢?原因在于:之前的抢购商品都不是什么稀缺性商品,而这次活动居然是飞天茅台 ,通过埋点数据分析,各项数据基本都是成倍增长,活动热烈程度可想而知!话不多说,直接上核心代码,机密部分做了伪代码处理。。。 public SeckillActivityRequestVO seckillHandle(SeckillActivityRequestVO request) { SeckillActivityRequestVO response; String key = "key:" + request.getSeckillId; try { Boolean lockFlag = redisTemplate.opsForValue().setIfAbsent(key, "val",

开源API网关Kong基本介绍和安装验证

南笙酒味 提交于 2020-12-30 17:02:01
本文将介绍开源API网关Kong。在GtiHub搜索API网关类的开源产品,可以看到Kong网关常年都是排第一的位置,而且当前很多都有一定研发能力的企业在API网关产品选型的时候基本也会选择Kong网关,并基于Kong网关进行二次开发和定制。 API网关概述 简单来说API网关就是将所有的微服务提供的API接口服务能力全部汇聚进来,统一接入进行管理,也正是通过统一拦截,就可以通过网关实现对API接口的安全,日志,限流熔断等共性需求。如果再简单说下,通过网关实现了几个关键能力。 内部的微服务对外部访问来说位置透明,外部应用只需和网关交互 统一拦截接口服务,实现安全,日志,限流熔断等需求 从这里,我们就可以看到API网关和传统架构里面的ESB总线是类似的,这些关键能力本身也是ESB服务总线的能力,但是ESB服务总线由于要考虑遗留系统的接入,因此增加了: 大量适配器实现对遗留系统的遗留接口适配,多协议转换能力 进行数据的复制映射,路由等能力 对于两者,我原来做过一个简单的对比,大家可以参考。 对于API网关进一步的功能介绍,可以我前面参考文章:《 一文详细讲解API网关核心功能和API管理扩展 》。 基于Openresty开发API网关 在谈API网关前,我们先谈下Openresty。在前面文章谈到过,当前适合用于API网关的架构,一种是基于Openresty的,一种是基于Go语言的。

VLC Scripting with Lua: Jump to a specific time in a file?

大城市里の小女人 提交于 2020-12-28 06:50:58
问题 This seems like it should be simple, but I'm coming up empty handed here. I'm trying to make a simple VLC script that checks if the "random" button is on, and if so when it jumps to a random file, instead of starting at time=0, it starts at a random time. So far, it's looking to me like it should be a playlist script and I can get the duration from the playlist object, but in this documentation page or on Google, I can't seem to find any way to jump to a specific time from within the Lua

VLC Scripting with Lua: Jump to a specific time in a file?

感情迁移 提交于 2020-12-28 06:50:58
问题 This seems like it should be simple, but I'm coming up empty handed here. I'm trying to make a simple VLC script that checks if the "random" button is on, and if so when it jumps to a random file, instead of starting at time=0, it starts at a random time. So far, it's looking to me like it should be a playlist script and I can get the duration from the playlist object, but in this documentation page or on Google, I can't seem to find any way to jump to a specific time from within the Lua