Skip to content
A test-driven implementation of an in-memory database with O(1) retrieval time and O(n) space constraints.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Running Tests

From inside the directory, run ruby test_database.rb

Using the Database

Two options:

  1. Straight from command line (does not work)

    1. Navigate to directory
    2. Run sh
    3. type database commands like:
      • SET Hello World
      • GET Hello
      • DELETE Hello
    4. WARNING: I was attempting to replicate exactly the input and output mechanism delineated in the prompt. However, the database does not hold state by this method. I messed with it for about 20 minutes, then decided that you're probably more interested in my database implementation than the exact input mechanism, and I moved on.
  2. Via irb

    1. Navigate to directory
    2. Type irb
    3. Type load 'database.rb'
    4. Instantiate database via, for example db = Database.instance
    5. Call methods on the db instance
    6. All method names are the lower case version of what is described in the prompt. For example, db.begin, db.commit, db.end
    7. I attempted to name these methods exactly as described in the prompt (removing the database object and having a file full of methods named things like BEGIN, DELETE, COMMIT), but it turns out a few of these are keywords in ruby. I'm not in the business of bogarting ruby keywords to make my databases, so I left it as an object.

Here is a screenshot of my irb console demonstrating the database at work:

database at work

Here is a screenshot of deletion inside a transaction:

deletion within transaction

You can’t perform that action at this time.