Comments (5)
Would you like the cache to be stored at a specific location on disk?
Would you like to create a single file per ip (like 1.1.1.1.txt or 1.1.1.1.json) or a single cache file for ALL?
What can of serialization would you like for on-disk storage? JSON? Binary (gob)? Plaintext?
from cli.
It would most likely be an implementation of the cache interface from the IPinfo Go SDK using BoltDB or similar as a single file database, and supporting TTLs & LRU eviction.
How do you support TTLs+LRU on a file-based cache?
TTL: lazy deletion; each entry has an expiry date attached to it, and when the entry is retrieved and it is determined that the expiry has passed, it is deleted and a cache miss is assumed.
LRU: when the file reaches some configured limit, a job is run which scans through the database and deletes the X oldest entries, e.g. X=1000, or however many are needed to reach back down to e.g. 50% capacity.
As an additional help, on every Xth (e.g. X=10) use of the CLI, a job is run before the CLI does its main work, which goes through the entire database, even if it's not full, and evicts expired entries. This amortizes the slowdown of a full database scan before the database gets full and the scan is too noticeable.
Just an FYI that this is not easy to implement well, so if any contribution is given it'd go under tight scrutiny and may or may not be accepted. We wanna get this one done really well.
from cli.
Another much simpler strategy, which wouldn't be too bad given the size of disks these days and how unnoticeable caches are to people (I'm shocked whenever I look at the size of cache folders that the apps I use get away with), we could just say: keep filling & using the cache until it's full (say 2GB max), then dump it and start again; also dump it forcefully every 24 hours as a "global" TTL.
from cli.
@UmanShahzad I believe the second approach would be easier to implement. We just have to decide how to get the appropiate folder depending on the plattform and write json files to it. The lib can already parse JSON
from cli.
@eacp We shouldn't write JSON files, because it would require a full re-write. Some people have done that but it's a terrible idea past like 100MB.
from cli.
Related Issues (20)
- Country flag emoji oddly displayed HOT 10
- Implement netIP functionalities in CLI HOT 1
- Bug in `ipinfo tool upper` HOT 1
- Windows 11 (Defender): Trojan:Win32/Bearfoos.B!ml Trojan Virus HOT 3
- Piping a list of IP addresses to map and summarize is NOT working HOT 1
- More basic IP tools
- "ipinfo tool aggregate" weirdness HOT 3
- Linux aarch64 not supported HOT 3
- API endpoint for usage HOT 3
- Tool → aggregate function throwing error at file input HOT 1
- Tool → `aggregate` function does not print IPs as is HOT 5
- IPinfo CLI tool command → `aggregate` closer inspection of operation recommended HOT 1
- Even with installation failure the CLI indicates success HOT 1
- Different GLIBC version in 3.3.0? HOT 3
- How it the CLI handles manual input of tokens?
- ipinfo no longer works on Windows 7, Windows Server 2008 HOT 1
- IPinfo CLI Download command: Invalid character 'U' looking for beginning of value
- Windows Defender flagging as Name: Trojan:Win32/Bearfoos.A!ml
- brew install ipinfo-cli
- The aggregate tool does not support IP range aggregation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.