有关注一个开源 API 网关项目 GoKu API Gateway CE
"args": [ "server", "-p", "3001" ]
如果是调试端口的话有个debuggerPort
参数
我代码里面都用的 @articles
,显示出来出错了
Rails 5 已经有 collection cache, jbuilder 也有 collection cache
jbuilder_cache_multi
,适用于增删改不频繁,缓存整个集合json.cache! @user1 do
json.partial! 'article', collection: @user2, as: :article
end
jbuilder_cache_multi
,缓存每个对象json.cache_collection! @user3 do |article|
json.partial! 'article', article: article
end
如果对象支持 cache_key
方法就用 cache_key
做缓存的 key,获取的时候使用 Rails.cache.fetch_multi
为什么不直接用 Rails.cache 的 cache_key_with_version
为什么不是直接使用 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
来实现吗?