Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zabolotnov87/geoip_redis
Put MaxMind GeoIP database to Redis
https://github.com/zabolotnov87/geoip_redis
geoip2 maxmind redis ruby
Last synced: 25 days ago
JSON representation
Put MaxMind GeoIP database to Redis
- Host: GitHub
- URL: https://github.com/zabolotnov87/geoip_redis
- Owner: zabolotnov87
- License: mit
- Created: 2015-11-11T12:52:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-01T01:32:04.000Z (almost 8 years ago)
- Last Synced: 2024-04-24T02:42:08.368Z (9 months ago)
- Topics: geoip2, maxmind, redis, ruby
- Language: Ruby
- Homepage:
- Size: 25.4 KB
- Stars: 22
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/zabolotnov87/geoip_redis.svg?branch=master)](https://travis-ci.org/zabolotnov87/geoip_redis)
# GeoipRedis
Puts MaxMind GeoIP2 database to Redis and allows to resolve country/city by ip. The main idea described [here](http://redis4you.com/articles.php?id=018&name=GeoIP+in+Redis).## Restrictions
* legacy version of GeoIP database isn't supported
* working only with IPv4 database## Installation
Add this line to your application's Gemfile:```ruby
gem "geoip_redis"
```And then execute:
$ bundle
Or install it yourself as:
$ gem install redis_geoip
## Usage
Working with GeoIP2 Country database:
* load:```ruby
require "redis"
require "geoip_redis/country_loader"redis = Redis.new(url: "redis://localhost:6379/4")
loader = GeoipRedis::CountryLoader.new(redis)loader.load_blocks("path/to/blocks_ipv4.csv")
loader.load_locations("path/to/locations.csv")
```* resolve country by ip:
```ruby
require "redis"
require "geoip_redis/resolver"redis = Redis.new(url: "redis://localhost:6379/4")
resolver = GeoipRedis::Resolver.new(redis)country = resolver.resolve("123.234.23.12")
```Working with GeoIP2 City database:
* load:```ruby
require "redis"
require "geoip_redis/city_loader"redis = Redis.new(url: "redis://localhost:6379/5")
loader = GeoipRedis::CityLoader.new(redis)loader.load_blocks("path/to/blocks_ipv4.csv")
loader.load_locations("path/to/locations.csv")
```* resolve city by ip:
```ruby
require "redis"
require "geoip_redis/resolver"redis = Redis.new(url: "redis://localhost:6379/5")
resolver = GeoipRedis::Resolver.new(redis)city = resolver.resolve("123.234.23.12")
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/zabolotnov87/geoip_redis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.## Licence
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).