Count Implementation
class Database | |
def initialize | |
@count = Hash.new(0) | |
@db = Hash.new() | |
end | |
# CRUD COMMANDS | |
def set(key, value) | |
@db[key] = value | |
@count[value] += 1 | |
return nil | |
end | |
def get(key) | |
@db.fetch(key, "NULL") | |
end | |
def count(value) | |
@count.fetch(value, 0) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment