为什么不是直接使用 redis 来设置过期时间
不是大佬,喜欢可以赚很多钱的语言
https://github.com/mperham/sidekiq/wiki/Advanced-Options
class HardWorker
include Sidekiq::Worker
MEMCACHED_POOL = ConnectionPool.new(size: 10, timeout: 3) { Dalli::Client.new }
def perform(args)
MEMCACHED_POOL.with do |dalli|
dalli.set('foo', 'bar')
end
end
end
那你要说是那个 API 了,不知道具体需求
params = { foo: 'bar', baz: 'qux' }
uri = URI('https://httpbin.org/post')
uri.query = params.to_query
url = uri.to_s
RestClient.post url, {}
请保持对 Ruby 新时代性能的关注。
我有一种错觉
https://github.com/rails/rails/pull/32828/commits/9082ed512a3f1bd65c725bfeb49ef59f9c992b7f 有人提交了 pull request 如果 ping 客户端超过 5 次没有回应就认为客户端掉线了
Rails caches Templates with the ActionView::Resolver::Cache. If you get the resolver you can then clear the context with clear_cache. In an ApplicationController you recieve the context via lookup_context.view_paths.paths.first. Just call clear_cache on the resolver and Rails will reload the cache at the next request.
ActionView::Resolver.clear_cache
试试
The Unarchiver 可以预览解压之后的文件名是不是乱码,对在 windows 上创建的压缩包很有用
工作五年一直用 Rails 写 API
刚好看到 okcomputer,内置了比较常见的一些检查
在用 ruby-china 客户端回复
puts :value # => value
puts "#{:value}" # => value
有什么不对吗?
看不太懂但很赞
.ruby-version
我用 restful 的风格客户端都觉得不好,还说接口返回的最外层一会儿是数组一会儿是对象无法处理
我用 jwt 可以把 token 的 iat 放在 token 里面,服务端保存最新的 iat,客户端请求的 iat 若小于服务端的 iat 就返回 401
顶,我都想去
可以做成类型微信网页授权的,微信是用 JS 在 APP 和网页之间通信的,这个库貌似可以 jockeyjs
sidekiq 作者推荐最多不要超过 50,如果 worker 里有读写数据库操作,不要超过数据库的 pool 数
不应该通过 nginx
来实现吗?
用 sidekiq-scheduler
就不需要 whenever
require 'sidekiq-scheduler'
class ProductScheduler
include Sidekiq::Worker
def perform
puts 'Hello world'
end
end
.
.
.
:schedule:
ProductScheduler:
every: '1m'
可以用sidekiq-scheduler,是结合了上面的rufus-scheduler
和sidekiq
,还在sidekiq
的后台管理页面里面集成了循环定时任务的管理
等改回去了,又有人说要改回来就尴尬了,可以自己改吧,然后加个主题功能,后台可以选择主题
model 也可以使用 namespace 吗,那对应的表名应该是什么样的?可以尝试指定表名