How to set a max access times within a limited time?

I want to limit access to certain resources base on following rules:

  1. each ip can only access the resources 333 times a day (or within
    the last 24 hrs)

  2. no more than X simultaneous connections and no more than Xr/s

Currently, nginx can handle rule 2 with the limit zone module.
http://wiki.nginx.org/NginxHttpLimitZoneModule

location /resource {
limit_conn gullag 1;
limit_req zone=qincheng burst=1;
}

How do I go about rule 1? Thank you!