Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2003, 05:27 AM
operator smooth operator smooth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 61 operator smooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Caching algorithm?

I have made a pretty fast (HTML-)template file scanner, which constructs template data using following steps:

1. load file into a safely padded string
2. scan for pairs of markup "delimiters" and construct variable fields and (recursively) sub-templates

This seems to work fast, loading a pretty complicated template takes less than 1 ms. But still, 1 ms is quite some time...

My component is an extension for PHP. I am not quite sure if it would be a good idea to introduce some caching, so that the constructed data structure could be stored and cloned on request, instead of scanning a file every time.

My idea is to have a memory limit for template cache, and do something like this when a template is loaded:

lookup in cache
if found
return a clone
else
load file
construct data
store in cache
while total memory used is greater than max allowed
delete "unpopular" templates from cache
return a clone of new data structure

Anybody knows an algorithm for finding cache entries, that are least frequently used? Or maybe some other caching approach?

Is it woth bothering, when the processing time that can be spared is less than 1 ms?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Caching algorithm?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap