TLDR; Don’t store Tweet ID’s as INT. Use BIGINT.
While writing a Twitter application in Rails I was having an issue saving tweets to the database.
A quick brief on the application: The app would download tweets from the mention timeline of a particular user. It would only download tweets it hadn’t already processed based on the last saved tweets unique id (as set by twitter). All the data from the tweets were making it into the database as expected but every time the application downloaded tweets it would re-download the same tweets.
While setting up a new Rails development environment I ran into the error bson keys must be strings or symbols. After some googling I found the following method to fix it:
/gems/bson-1.2.0/lib/bson/bson_c.rb:24:in `serialize': keys must be strings or symbols (TypeError) rvm gemset empty bundle install /fixed
This is just a quick bit that I learned early in my Ruby career and always found interesting.
Symbols Are Memory Leaks
So is this the end of the world?
No
Symbols are a unique thing in ruby. It’s immutable, constant and unique. You can re-use the same Symbol over and over without allocating extra memory. As opposed to using a String over and over which will allocate memory with each instance.