Time related conditions


we are looking for a way to change the nginx’s behavior if certain
conditions related to time are met. like for example if one source ip
requests more than 10 times a minute we would like to redirect it to
somewhere else. or also if one certain cookie from a client gets
received more than x times per x seconds we would like to deliver an
alternative page. is there any way how nginx can do things like this?
if not i might start to write a module to provide this kind of
behavior, since i think it’s probably not very hard to implement.