开发者

How do make a model to for logging IPv4 and IPv6 ip addresses for quick lookup in Rails 3?

开发者 https://www.devze.com 2023-02-02 13:19 出处:网络
I\'m looking for a way to log IP addresses and user agents and then query against the list by IP. I was hoping to store the IP as efficiently as possible because the log could grow to be very large ov

I'm looking for a way to log IP addresses and user agents and then query against the list by IP. I was hoping to store the IP as efficiently as possible because the log could grow to be very large over time. What data 开发者_运维知识库type would I use for the IP address, string, long, or decimal? and how do I index the IP column for speed the Rails way?

Thanks!


Most efficient way is to use the IPAddr class, and then store them in your database as integers

0

精彩评论

暂无评论...
验证码 换一张
取 消