Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP或Javascript中的VCL和std.strtol_Javascript_Php_Varnish_Varnish Vcl_Fastly - Fatal编程技术网

PHP或Javascript中的VCL和std.strtol

PHP或Javascript中的VCL和std.strtol,javascript,php,varnish,varnish-vcl,fastly,Javascript,Php,Varnish,Varnish Vcl,Fastly,出于AB测试目的,我们将用户Id的unqiue散列生成VCL中的bucket值(通过Fastly CDN) 首先,将用户id散列为MD5字符串。然后是前8个字符。用于将其转换为整数值的std.strtol函数。然后将该值用作randomint\u seed函数的种子 我们正在努力用任何其他语言(寻找PHP或javascript)实现与std.strtol和randomint\u seed相同的功能。我们需要在不同的语言中获得相同的结果 有什么建议吗 set var.backResult =

出于AB测试目的,我们将用户Id的unqiue散列生成VCL中的bucket值(通过Fastly CDN)

首先,将用户id散列为MD5字符串。然后是前8个字符。用于将其转换为整数值的
std.strtol
函数。然后将该值用作
randomint\u seed
函数的种子

我们正在努力用任何其他语言(寻找PHP或javascript)实现与
std.strtol
randomint\u seed
相同的功能。我们需要在不同的语言中获得相同的结果

有什么建议吗

set var.backResult =
  randomint_seeded(1, 4,
    std.strtol(
       substr(
         digest.hash_md5(req.http.X-Development-UserId)
       , 0, 8),
    16)
  );