Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:37:30+00:00 2026-05-24T18:37:30+00:00

I’m building a server that implement the tftp protocol. My homework requests the creation

  • 0

I’m building a server that implement the tftp protocol. My homework requests the creation of a cache of recent requested files. What I would like to understand is about design, watch the example:

Server request file to the cache
The cache doesn’t have file
The cache read from filesystem the file
The cache serves the file to the server

Should the cache read from the file system or should the server read from the cache and if the file is missing, read it from the file system and put it in the cache?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:37:33+00:00Added an answer on May 24, 2026 at 6:37 pm

    From a complexity standpoint, I would definitely recommend that the cache reads the file from the file system. Your implementation will be much cleaner that way.

    Digging deeper: you’re touching on the single responsibility principle. Ideally, you want components of your system to do one thing, and do it well. What you are trying to avoid is a God object that does everything, as this stops your code from being scalable and reusable. Now lets take a look at the two options you presented:


    Option 1: Server reads file system & saves to cache.

    In this instance, the server is the center of the universe. The cache serves as nothing more than a memory pool for the server, and without the server, it has little purpose. The server must know everything about both the file system and the cache, and enhancing the system requires that the server be changed.

    This description alone makes it obvious why it breaks the single responsibility principle. Any change to any component of the system demands a change to the server–this is bad.


    Option 2: Cache reads file system.

    In this option, the cache serves as a complete abstraction between the server and the file system. The server does not need to know how the cache works. For that matter, there could even be multiple levels of caching! No matter how it works, the server doesn’t have to care. The server uses the cache for one use and that is to retrieve a file.

    The division also goes both ways. The cache does not need not know how it is being used, but merely that it exists to make accessing the file system faster. This allows it to be switched out with something better at a later date (if you decide to do so), and also makes it so that it can be reused in other projects you create.

    Your code will be much easier and much cleaner if you go with option 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I am writing an app with both english and french support. The app requests
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.