在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Shopify/wolverine开源软件地址(OpenSource Url):https://github.com/Shopify/wolverine开源编程语言(OpenSource Language):Ruby 98.9%开源软件介绍(OpenSource Introduction):WolverineWolverine is a simple library to allow you to manage and run redis server-side lua scripts from a rails app, or other ruby code. Redis versions 2.6 and up allow lua scripts to be run on the server that execute atomically and very quickly. Wolverine is a wrapper around that functionality, to package it up in a format more familiar to a Rails codebase. How do I use it?
gem 'wolverine'
-- app/wolverine/util/mexists.lua
local exists = {}
local existence
for _, key in ipairs(KEYS) do
table.insert(exists, redis.call('exists', key))
end
return exists
Wolverine.util.mexists(['key1', 'key2', 'key3']) #=> [0, 1, 0] Or Wolverine.util.mexists(:keys => ['key1', 'key2', 'key3']) #=> [0, 1, 0] Methods are available on Nested Lua ScriptsFor lua scripts with shared code, Wolverine supports ERB style templating. If your app has lua scripts at
that both have shared lua code, you can factor it out into a lua "partial":
-- app/wolverine/shared/_common.lua
local function complex_redis_command(key, value)
local dict = {}
dict[key] = value
end -- app/wolverine/do_something.lua
<%= include_partial 'shared/_common.lua' %>
complex_redis_command("foo", "bar")
return true -- app/wolverine/do_something_else.lua
<%= include_partial 'shared/_common.lua' %>
complex_redis_command("bar", "baz")
return false
ConfigurationAvailable configuration options:
If you want to override one or more of these, doing so in an initializer is recommended but not required. See the full documentation for more details. More informationFor more information on scripting redis with lua, refer to redis' excellent documentation: http://redis.io/commands/eval |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论