如何使用N个并发用户测试我的Rails应用程序?
这些模拟用户将执行一些操作,如上传/下载文件等.
是否有支持此功能的框架或免费工具?
我的应用程序有一个功能,允许管理员通过 GUI 更改 cache_store 配置。然后新的配置将立即生效。
我的 production.rb 中的默认cache_store:
config.cache_store = :memory_store
Run Code Online (Sandbox Code Playgroud)
管理员可以选择更改为将 memcached 与 Dalli 存储结合使用。我尝试更改 Rails.application.config.cache_store:
Rails.application.config.cache_store = :dalli_store, 'localhost:11211', 'localhost:11212'
Run Code Online (Sandbox Code Playgroud)
但 Rails.cache 没有改变:
Rails.cache
=> <#ActiveSupport::Cache::MemoryStore entries=0, size=0, options={}>
Run Code Online (Sandbox Code Playgroud)
有办法做到这一点吗?
在MRI Ruby中,我可以这样做:
def transfer
internal_server = self.init_server
pid = fork do
internal_server.run
end
# Make the server process run independently.
Process.detach(pid)
internal_client = self.init_client
# Do other stuff with connecting to internal_server...
internal_client.post('some data')
ensure
# Kill server
Process.kill('KILL', pid) if pid
end
Run Code Online (Sandbox Code Playgroud)
但是上面的代码不会在jRuby中运行,因为它不支持'fork'方法:
NotImplementedError: fork is not available on this platform
Run Code Online (Sandbox Code Playgroud)
在jRuby中有没有替代解决方案?
谢谢.
我试图通过Ruby中的密码"DES-EDE3-CBC"加密数据,然后用Java解密加密数据.
这是Ruby中的代码我做加密:
require 'digest'
require 'openssl'
require 'base64'
ALG = "DES-EDE3-CBC"
key = "80f28a1ef4aa9df6ee2ee3210316b98f383eb344"
cipher = OpenSSL::Cipher::Cipher.new(ALG)
cipher.pkcs5_keyivgen(key, nil)
cipher.encrypt
data = "hello"
result = cipher.update(data)
result << cipher.final
# Write the data to file.
File.open("enc.txt", "wb"){|f| f.write result}
Run Code Online (Sandbox Code Playgroud)
然后用Java解密:
import java.security.*;
import java.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
public class Test{
public static void main(String[] args) throws Exception {
String key = "80f28a1ef4aa9df6ee2ee3210316b98f383eb344";
// Init the key
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
Key secretKey …Run Code Online (Sandbox Code Playgroud) 根据https://github.com/mperham/dalli,我们可以配置多个Memcache服务器.但我不确定它是如何工作的.
假设我们使用的memcache集群有两个服务器:memcache1(box1)和memcache2(box2).
到目前为止,我的理解是,我不确定缓存过期在集群环境中是如何工作的.特别是,当我们想要急切地使缓存过期时,它会在所有盒子上到期吗?
鉴于我们在TWO rails服务器中具有相同的配置:
config.cache_store = :dalli_store, 'memcache1', 'memcache2'
Run Code Online (Sandbox Code Playgroud)
您如何看待这个用例?
谢谢你的兴趣.