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

6
votes
1answer
88 views

Thread-safe memoizer

I have searched around but I was not able to find a complete implementation of the memoize pattern in a multithreaded context. It's the first time playing with thread synchronization. The code seems ...
3
votes
2answers
48 views

Resource caching in Java with soft references

I'd like to cache some heavy resources locally. The goal of this implementation is to have be able to load resources for an unknown amount of time and then keep them in memory and finally evict them ...
2
votes
1answer
30 views

Simple BloomFilter Class

We have some BloomFilters (like a java.util.set without deletion) and we store them in ehcache (you can think it's as a ...
3
votes
1answer
65 views

Spring oauth2 token store supported by redis

I had to make a demo for Spring oauth2 with redis store for tokens. I started with the sparklr2 (with tonr2) sample app from here. They are demo apps to show oauth2 powered by spring. Sparklr is the ...
1
vote
1answer
70 views

Thread safe double buffered cache

I want cache object for one value, which have two expiration limits. One "soft" limit indicating "value is old, but is still valid, but is good time for reload the value". And one "hard" limit ...
0
votes
2answers
104 views

Caching using phpFastCache

I have a class that holds functions for caching using PHPFastCache. There are quite a few static functions in here and for each one I am declaring: ...
2
votes
1answer
119 views

Simple thread-safe loading cache based on RxJava

I'm sketching a simple thread-safe cache which can load missing values. It is based on RxJava's Observable which also means that it should be possible for a client to join a request for value which is ...
4
votes
3answers
89 views

Thread safe cache for write through and writeback

This cache is like a list where new elements are inserted in the middle, cache hits are put to head of the list and replaced elements are taken from the end. Would I just use a list the lookup would ...
3
votes
1answer
199 views

Redis Cache Data source code - Retrieve/Set/Invalidate actions

This is my RedisDataSource code. What I am mainly interested in is how the retry policy could be improved and if using WindowsAzure Trainsient Fault Handling this case (using Redis Azure Cache) makes ...
1
vote
1answer
58 views

Caching DOM-queries

I've been optimizing my code and I always tend to cache common selectors like this (jQ): ...
3
votes
1answer
65 views

Reducing lock contention for a caching utility, or make it totally lockless but threadsafe

My Java program is a module called configProxy which fetches configuration entries from a remote node (say from a Redis instance). When the caller calls the ...
9
votes
2answers
101 views

Inspector Rubberduck - Take Two

Release 1.1 of Rubberduck only had a handful of implemented code inspections, more as a proof of concept than anything else. For release 1.2, we now have 19 implementations of our ...
7
votes
1answer
166 views

Cache for JSON API

I am working on a small project which utilizes a 3rd party API. Many of the queries from the API can take 5-10 seconds so to keep the front end moving a bit faster I decided to cache the responses ...
5
votes
1answer
165 views

Caching data on disk in iOS

I've got an app that's got an activity/timeline like view. Since I don't want to retrieve the entire timeline every time, I'm caching all the events. Currently, this is how I go about it: ...
6
votes
1answer
179 views

Choosing a random flat color

I have a big array of custom flat colors with perhaps 100 lines: ...
2
votes
1answer
64 views

LRU Cache Design using LinkedHashMap

This is a follow-on qestion from: LRU cache design Revised Implementation ...
3
votes
1answer
124 views

Concurrent LRU cache using sychronizedMap() or ReadWriteLock

Trying to implement a simple, thread-safe LRU cache that's meant for "read mostly" use. Collections.sychronizedMap() Clean, simple, not much else to say. ...
6
votes
1answer
343 views

LRU cache design

Idea The cache is nothing but a circular arrayList. This list contains Entry<K,V>. Whenever new entries are coming, add ...
3
votes
0answers
77 views

Caching in PHP using the filesystem

I wrote a simple class to cache data on a filesystem. The class also provides an internal cache using a static variable to avoid reading from disk for each request. ...
0
votes
1answer
86 views

A double mapped cache with WeakReferences for second key type

I needed a way to cache a large number of objects with two different types of keys. In my case: A String key represents my object in a serialized form. This way ...
2
votes
1answer
534 views

Local image cache for external images

I have written a simple image cache script, the purpose is to load the image locally, so i can control the cache times of the images, and i have better load times than the host server, (battle.net ...
5
votes
2answers
251 views

Time Sensitive ConcurrentDictionary

In our application, we have many function calls that we want to cache the results of. However, the result of these functions depends on database calls, so we want this cache to refresh every so often ...
5
votes
3answers
696 views

Map with different types for values

I am trying to implements a map (that can work as a cache) that has strings as keys and values of different types. In my real case once set the key/values in the map will not change. I used these ...
3
votes
2answers
250 views

Correct way of implementing thread safe factory with caching?

I have a ConnectorFactory that creates Connector objects based on parameters like URLs, username and passwords. The ...
1
vote
1answer
225 views

Memory cache service

I am repeating this code at lot of places: ...
2
votes
1answer
103 views

Clear cache files older than 30 minutes

This is what I came up with to delete files not modified within the last 30 minutes from a subdirectory named cache. ...
10
votes
4answers
401 views

Ugly optimized caching of SimpleDateFormat

Concerning the optimization of this simple function String formatDate(String format, Locale locale, Date date) {...} formatting a ...
3
votes
0answers
174 views

Rails app that scrapes forum using Nokogiri gem

I've built a website that scrapes a guitar forum's pages and populates Rails model. I'm using rake task along with heroku scheduler to run background scrapes every hour. On the homepage, the forum ads ...
3
votes
2answers
540 views

Thread-safe, in-memory LRU cache with a maximum item count of 10

I'm attempting to master LRU Caching. It must be thread safe, and it should preferably perform as well as web image-cache, (avg ~1MB). Please take a look to see if there's anything wrong, amiss, ...
2
votes
2answers
123 views

Database mirroring cache

I generally prefer to work with EF by specifying exactly the data to fetch from the DB with regards to Navigation Properties/Lookups and the like, so we wrote this cache system to limit the number of ...
3
votes
1answer
931 views

Using EHCache the right way

I use EHCache to maintain a mostly read-only cache of results from database queries. It works perfectly for over a dozen queries. However, there is one table which needs an odd access method that is ...
4
votes
2answers
1k views

Simple LRU cache with an expiration time

How can I improve the performance of the code below? ...
4
votes
1answer
129 views

Python caching generator

Is this the correct way to cache a generator in Python, without iterating over it right away (for example using list() over it)? ...
3
votes
2answers
104 views

Azure cache getoradd (without locking)

Inspired by the non-locking implementation proposed in this post, the following code is an attempt to (about) do the same using the azure cache. As I'm totally green on the Azure cache I'd appreciate ...
12
votes
4answers
269 views

I'm not sure if I still love Fibonacci, but my code is getting better. How much better?

Technically, this is a follow up to these two questions, but I have taken a radically different approach. Everybody Loves Fibonacci Does everyone still love Fibonacci I finally allowed myself to ...
1
vote
0answers
283 views

HttpRuntime.Cache cache manager class

I am making code review of legacy class, which manages caching logic. Caching logic uses ASP.NET webforms HttpRuntime.Cache. I know class, that is posted below, is ...
4
votes
2answers
543 views

Creating a cache manager

I am purely new to C++ memory management. Am I on the right path, or should I employ a different design strategy or a different memory manager policy (such as ...
2
votes
1answer
163 views

Is my ObjectCache wrapper sound?

Wrapper: ...
1
vote
1answer
72 views

Using Redis to store word occurences

I am doing a project where I am analyzing a group of Tweets. What I need to do is find the occurrence of each individual word. I am fairly new to Redis, so I am not quite sure that my solution is ...
4
votes
1answer
244 views

Using the Rotten Tomatoes API

This is a Python module I made to search the Rotten Tomatoes movie API. It caches the search results in a SQLite database. What improvements can I make to the cache system? Is there a better way ...
4
votes
2answers
321 views

ASP.NET MVC architecture questions

I haven't done much .NET development in several years. Now I'm enjoying some of the new stuff with modern .NET. I just want to make sure I'm using things correctly. I'm a solo developer with no one ...
3
votes
2answers
5k views

Generic, thread-safe MemoryCache manager for C#

Using this question as a base, and using some of the advice in the answers, I wanted to build out something that would be generic, thread-safe, and easy to use for at least one current and several ...
2
votes
2answers
71 views

JavaScript bookmarklet with a 24 hour cache

I'm working on a bookmarklet that will be cached for 24 hours only, after that time it will be reloaded from the original source. Is there something I could improve? ...
5
votes
1answer
416 views

HTTPCache and MemoryCache cross dependency

After asking a question on StackOverflow about the two .NET caching systems taking dependencies on each other I gave implementing them a go. I posted them as my own answer there but before accepting ...
15
votes
7answers
2k 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
89 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 ...
10
votes
1answer
212 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
1k views

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. Am I doing it right? ...
1
vote
1answer
318 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
32 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: ...