A cache is a component that transparently stores data so that future requests for that data can be served faster.

learn more… | top users | synonyms

14
votes
7answers
1k views

Why does caching of string objects perform faster?

I'm trying to implement String-Pool. I'm maintaining a HashMap<String,String> to store the keys. ...
2
votes
1answer
52 views

LRU Cache with a static variable for garbage value

I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called ...
9
votes
1answer
163 views

Allowing user space file-system to (kind-of) keep more than maximum number of files open

The linked code below is meant to be used in a user space file-system (fuse). Given that multiple processes may have multiple files opened on the file-system, the files on the specific user space ...
3
votes
2answers
79 views

A generic MemoryCache class

I want to have a caching class to cache different types, I want each type to be cached in a different MemoryCache but in a generic way, here is my implementation: ...
1
vote
1answer
88 views

Performance issue of LFU-like web caching replacement algorithm

I have implemented a simulation program that runs LRU and another web caching algorithm called Sliding Window LFU. I want to compare them both in terms of the hit rate and their run time. SW-LFU works ...
1
vote
1answer
22 views

Loading Recent Posts In Session? [closed]

I have a PHP code structure where I cash some pages in sessions. Example: I have a page which shows last 10 user posts, what I do is to load 10 posts and store then in session: Page Class: ...
3
votes
2answers
105 views

In-memory cache implementation revisited

As a follow-up on my earlier question, here is the new implementation. The major change is now that the base class just deals in ICacheValue values which are ...
3
votes
1answer
51 views

htaccess for URL remapping, caching, and compression

I have been collecting snippets from all over the place and then put them all together creating the following .htaccess file. I really don't understand if what I have done below is good/should work ...
0
votes
0answers
24 views

Adding viewstate based property and implication in future converstion to mvc in asp.net forms project

Suppostedly adding another viewstate based property in user control (riddled with similar properties) incur technical debt in future effort to convert projects to MVC (comment made by one of my ...
8
votes
1answer
120 views

Cache wrapper - Generics vs Dynamic

I've implemented a common wrapper pattern I've seen for the .NET cache class using generics as follows: ...
5
votes
3answers
108 views

Class with a temporary buffer: Tradeoff between memory usage and execution speed

Consider the following two classes class foo{ // huge data structure - 400-500 bytes per instance }; class Bar{ void get_foo(int n, foo& f); } In my ...
7
votes
1answer
809 views

In-memory cache implementation

A few years ago I required a lightweight in-app-in-memory cache. Requirements: Time complexity O(1) for individual element read/write access Space complexity ...
3
votes
1answer
105 views

Function to delete oldest items out of HTML5 localStorage. Can I make it more efficient?

In a current javascript project, I'm working with the browsers localStorage, and it will pretty consistently be full. To overcome this, I wrote a wrapper to surround the localStorage object that would ...
5
votes
1answer
56 views

Optimize text to ascii lookup map and scalability

Is there a more optimal way of retrieving the character for the letter? I would assume that I would just replace my Entry set loop with another map, but I do not want to bloat the code, because it ...
4
votes
1answer
76 views

Caching a function view for a day

I am writing a flask app that I will deploy it on Heroku to test it. There is a page that will generate daily photos and information based on a JSON file. The view is valid for 24 hours beginning from ...
4
votes
1answer
134 views

In-memory data cache architecture for data transfer

I am writing a cron job to manipulate and transfer remote data. I need to cache data from a table, process it, merge with previous table, iterate the process, and eventually send the result data to ...
3
votes
1answer
100 views

How to improve this session cache to search faster

I have this code which will store user session credentials: ...
5
votes
1answer
172 views

A Simple Cache class

“There are only two hard things in Computer Science: cache invalidation and naming things.” -- Phil Karlton That being said, I created this SimpleCache class which I intend to use to cache ...
1
vote
0answers
81 views

In-memory data cache architecture

I am designing basic in-memory cache storage with thin CRUD (actually CRD) interface. The design is inspired by the Backend solutions such as Parse and StackMob. Main requirements: Cache consists ...
5
votes
1answer
153 views

Generic pure functions memoization

I like to create tools for memoization since it can sometimes be useful. I recently created a generic tool for memoizing pure functions results. Here is an example og how it works: ...
6
votes
1answer
92 views

Optimize RecursionArray interface

I created a class a while ago that I named a "Recursion Array". It is a way to create dynamically memoized sequences such as the Fibonacci sequence or the factorial numbers sequences. The concept is ...
1
vote
0answers
108 views

Improve the architecture to cache data

I cache the data and use local database in my Windows Phone app. Algorithm is very simple: Get data from DB and show in UI Get data from a web service and show in UI Update data in DB from the web ...
1
vote
1answer
1k views

Design LRU cache interview questions

Code reviewers, I request you review the code and suggest all tips for improvement. ...
3
votes
1answer
341 views

Locking during cache population

Here I want to lock when populating a particular cache object, without blocking other calls to the same method requesting Foos for other ...
1
vote
0answers
135 views

Combine and minimize all .js files in parent folder

I'd appreciate some feedback on my latest PHP script. It is supposed to work like this: When obtained, it checks whether the cache is still up-to-date IF YES, return the cache; IF NOT, reset the ...
3
votes
2answers
136 views

Perl script for generating iTunes xml Metadata for MP3 CDs/DVDs

Many years ago, I wrote a script in Perl that was meant to create a cached metadata of MP3 files (in Apple's plist/XML format) which iTunes uses when you insert a CD/DVD full of MP3 files (the same ...
1
vote
0answers
92 views

Memcached caching

I wanted to create a class to cache dynamic PHP output (or a portion of it from one page) using Memcached key/value story. Basically it checks to see if the file has been cached already, if it has, it ...
1
vote
1answer
98 views

Cache mechanism with duration

I want to implement in my code a cache mechanism with a fixed duration. For example an iframe will be cached for one hour, or a script file will be cached for 24 hours. This is how I implemented it, ...
2
votes
1answer
354 views

How to create a simple stateless cache class in PHP

i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like ...
4
votes
1answer
356 views

Implementing cache for server. Any suggestions?

I've just implemented a cache for my server, and I'd like your thoughts about performance improvements and maybe some possible bug fixes: ...
1
vote
1answer
146 views

Simple cache mechanism?

In my system I frequently require data by Ajax requests. For example, different lists, content of modal dialogs, etc. This data can't be changed after request, so I wrote cache mechanism which stores ...
3
votes
1answer
372 views

Java thread safety and caching techniques

This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class ...
2
votes
1answer
96 views

Sprite cache for SFML sprites

I'm trying to make a sprite cache for SFML sprites. The basic idea I got was to use a map of an enum and a sprite pointer. Then when I would ask for a certain ...
4
votes
1answer
55 views

Elegant memoizing

I wanted an elegant way to implement memoizing. Here is what I came up with: ...
0
votes
1answer
70 views

What is the better way to retrieve value from this cache implementaion?

I have the following methods in CacheUtil class ...
1
vote
1answer
103 views

Wraper for caching methods in ASP .Net?

I have written a caching wrapper method for some of my services. The actual wrapper method is written as follows: ...
6
votes
1answer
316 views

Ability to forget the memoized supplier value

Guava has a feature request which is asking to provide the ability to forget memoized value on a given supplier. On top on that I needed another functionality where if during the calculation of ...
10
votes
1answer
446 views

Improve Parallel Cache with Reactive Extensions & Unity Interception

The requirement is to be able to cache method invocations made on a boundary layer (Services layer). I'm using Unity to inject the concrete implementation of the Service layer classes. The ...
5
votes
2answers
247 views

Using different instances of an object to lock threads

I'd like to use lock objects that are specific to the person I'm updating. In other words, if thread A is updating Person 1, thread B is blocked from also updating Person 1, but thread C is not ...
1
vote
1answer
4k views

How to correctly use lock when adding/renewing cached data in asp.net cache?

This is sort of a follow up question on http://stackoverflow.com/questions/754661/httpruntime-cache-best-practices/11431198 where a reply from frankadelic contains this quote and code sample from ...
3
votes
1answer
576 views

caching in WCF web service

I want to realize caching in WCF web service. I'm using the following code: ...
1
vote
3answers
119 views

Caching a JS selector then only using it once

I have this code: ...
4
votes
3answers
835 views

Code Review for generic cached IEnumerable<T>

I've an IEnumerable source which takes time to generate each item. Once an item is generated I want to cache it to avoid recomputing same. I want to separate out caching logic from original source. ...
3
votes
1answer
700 views

Thread safe cache implementation

Please review this implementation of thread-safe chache. ...
1
vote
2answers
290 views

Improvements and advice for my Cache class

After reading a bit about the System.Runtime.Caching in the .net 4 framework I've added a simple Cache class to my application. Can I improve it or add additional useful functionality? Typing it out ...
2
votes
2answers
522 views

C# small caching API

...
14
votes
2answers
715 views

Lock-free cache oblivious n-body algorithm

I'm currently looking at, from a rather high level, the parallelization of the gravity calculation in an N-body simulation for approximating a solution to the N-body problem. The simple form of the ...
2
votes
3answers
315 views

Public property, backing up by a private field, with caching and null checking inside

I have a private field called individualProfile (camelCase) and I've created a public property called IndividualProfile ...
2
votes
1answer
102 views

Does this function cache correctly?

I want to limit the load so I rewrite the most expensive method and add caching, both memcache and cache-control: ...
4
votes
1answer
2k views

An LRU cache template

I recently implemented a cache for a pet project of mine. The main objectives behind this implementation were: Support move-only types for values: C++11 is here, and some of the objects that will be ...