我正在使用RsJS 5(5.0.1)在Angular 2中缓存.它运行良好.
缓存功能的核心是:
const observable = Observable.defer(
() => actualFn().do(() => this.console.log('CACHE MISS', cacheKey))
)
.publishReplay(1, this.RECACHE_INTERVAL)
.refCount().take(1)
.do(() => this.console.log('CACHE HIT', cacheKey));
Run Code Online (Sandbox Code Playgroud)
该actualFn是this.http.get('/some/resource').
就像我说的,这对我来说非常合适.缓存从observable返回持续时间RECACHE_INTERVAL.如果在该间隔之后发出请求,actualFn()则将调用该请求.
我想弄清楚的是当RECACHE_INTERVAL到期和actualFn()被调用时 - 如何返回最后一个值.在RECACHE_INTERVAL到期和actualFn()重放之间有一段时间,observable不返回值.我想及时消除这个差距,并始终返回最后一个值.
我可以使用副作用并.next(lastValue)在等待HTTP响应返回时存储最后一个好的值调用,但这似乎很幼稚.我想使用"RxJS"方式,一种纯函数解决方案 - 如果可能的话.
我正在使用动态创建的Firefox配置文件在包含多个节点的Selenium网格上运行多个测试,如下所示:
$firefoxProfile = new FirefoxProfile();
$capabilities = DesiredCapabilities::firefox ();
$capabilities->setCapability(FirefoxDriver::PROFILE, $firefoxProfile);
$this->webdriver = RemoteWebDriver::create("http://my.tests.com", $capabilities, 5000);
Run Code Online (Sandbox Code Playgroud)
但是每次集线器选择具有先前运行的Firefox实例的节点时,它都使用相同的配置文件并丢弃先前运行的会话.这是因为应用程序使用相同的cookie进行身份验证.
是否有某种方法可以强制selenium网格动态创建一个新的配置文件并获得一个全新的firefox实例?
为了启动集线器,我目前使用以下命令行
java -jar /opt/selenium/selenium-server.jar -trustAllSSLCertificates -timeout 300 \
-role hub -newSessionWaitTimeout 60 -maxSession 2 \
-port 9444 -nodeTimeout 300 \
-browserTimeout 300 &
Run Code Online (Sandbox Code Playgroud)
为了让节点启动我使用
xvfb-run -n 99 --server-args="-screen 0 800x600x16 -ac" \
-a java -jar /opt/selenium/selenium-server.jar -role node \
-browser browserName=firefox,maxInstances=2 \
-hub http://my.tests.com:9444/grid/register
Run Code Online (Sandbox Code Playgroud)
奇怪的是,当我设置一个独立的Selenium服务器时,它会创建多个firefox实例,因为我希望...