GithubHelp home page GithubHelp logo

address_cache's Introduction

#Overview

This project implements a addresscache interface for a fictional InetAddress cache. The cache has a "Last-In-First-Out" (LIFO) retrieval policy and a "First-In-First-Out" (FIFO) eviction policy. Methods such as peek(), remove() and take() retrieve the most recently added element and an internal cleanup task that in periodic intervals removes the oldest elements from the cache.

#Instructions

  • The goal is to write the most beautiful and functionally correct code possible
  • This repo includes an Implementation for AddressCache
  • A cleanup task runs every 5 seconds to evict expired address's
  • The caching time of an element is configurable by the user
  • The implementation includes a set of tests to check the correctness
  • The cache is designed for optimal asymptotic performance

#Implementation

  • The cache is designed with a HashMap and LinkedList
  • I implemented my own LinkedList because a ListIterator/Iterator in Java's LinkedList gets invalidated if a new element is added or deleted from the LinkedList
  • The cache entries are stored in the first LinkedList which are sorted by least recently use
  • The cache entries are stored in the second LinkedList which are sorted by expiration time
  • The User can specify the size and and the caching time
  • Each cache entry get a timestamp when added into the cache
  • A timer runs every second and deletes expired cache entries from the cache
  • To compile the code and run the test use Maven:
    • $ mvn compile
    • $ mvn test

address_cache's People

Contributors

arnold1 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.