[erlang-questions] How to not cache a certain function in yaws

Anders Nygren <>
Mon Mar 2 17:11:32 CET 2009


2009/3/2 Salonee Sinha Roy <>:
> I have a web app in yaws. A part  the code is supposed to randomly generate
> a temp string using the following code.
>
> genname(0, L) -> L;
> genname(N, L) ->
>     R = random:uniform(123),
>     case isalphanum(R) of
>     true -> genname(N-1, [R|L]);
>     false -> genname(N, L)
> end.
>
> Each time I call genname(8,[]), I want to generate a different string.
> However because of the caching behavior of yaws ( I think ), each time I
> call genname(8,[]), it always returns the same string. Is there a way I can
> change this.
>
> Any help would be appreciated
> Thanks in advance
> Salonee.
>

The problem is that random is initailized with a default seed in each
process. And since You dont seed it yourself it will generate the same
sequence of numbers in each process.

add something like this

{A1,A2,A3} = now(),
random:seed(A1, A2, A3)

before the call random:uniform(123)


/Anders



More information about the erlang-questions mailing list