Questions tagged [cache]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
65 views

Simple MemoryCache implementation for thread safe caching

After much prompting from this post I wanted to build a simple, in-memory, thread-safe cache. The only caveat (as far as I was originally concerned) was the need for two different absolute expiration ...
-1
votes
1answer
48 views

Thread-safe LRU cache in Python

I've written a simple LRU cache class and I am trying to make it thread-safe. My thoughts are that I just need to wrap the code that updates the ordered dict in a lock so that if any thread is writing ...
4
votes
2answers
44 views

Python persistant cache for non-pythonic objects

I am trying to implement a cache which can be persisted. Also, some of the functions that I am trying to cache takes arguments that are not python objects (external library objects). But they seem to ...
0
votes
1answer
43 views

How do I divide Dao and Dao-Cache into different modules? [closed]

I want to improve performance for api. I design cache in dao layer. I use caffine cache. Basic code is: CacheConfig.java ...
6
votes
2answers
123 views

Another dynamic array implementation in C

I saw quite a few posts about making a dynamic array so I tried making my own for learning purposes. Here it is: ...
0
votes
0answers
51 views

Performance discrepancy between Windows and Ubuntu for a video-memory-based virtual array implementation

I implemented virtual array using OpenCL and graphics cards as backing store, with caching some of data on RAM using a LRU algorithm and accessing data through some simple setters/getters. Accession ...
3
votes
2answers
59 views

An expirable LRU cache implementation

I implemented an ExpireLRUCache class, which will clear the data when it times out. There are two ways to achieve this: Use a timer to clear the expire data Call ...
4
votes
1answer
128 views

Efficient vector-like polymorphic container which retains type information

This is my attempt of implementing an efficient, cache-friendly, vector for polymorphic objects. From now on I will refer to "virtual functions" as functions which are dependent on an object'...
3
votes
2answers
62 views

Caching that resets itself under certain circumstances: Reduce boiler plate code

In my machine learning programs I have the typical situation where I need to perform certain operations on data, which results in the following graph: data --op A--> intermediate_state --op B-->...
2
votes
1answer
138 views

Thread-safe LFU Cache

I am trying to implement a thread-safe LFU cache algorithm, please review my code and would really appreciate some criticism or suggestion. (on naming, design, data structures used, anything) Some ...
1
vote
1answer
196 views

Thread-safe LRU Cache Implementation in Java

I am trying to implement a thread-safe LRU cache algorithm, please review my code and would really appreciate some criticism or suggestion. Some assumptions: capacity will be larger than 0 Some ...
1
vote
0answers
19 views

Metaprogamming elixir for module proxy

I'm working on my first real Elixir application, after dabbling for a few years. In my elixir/phoenix application I have to work with data over an external REST API. For my purposes, I can tolerate ...
5
votes
1answer
229 views

HSTS Recommendations in .htaccess

Please see my previous post in the below hyperlink I've updated my .htaccess file to account for an HSTS, along with many of the recommended changes. See the ...
4
votes
1answer
154 views

.htaccess Recommendations

I have a personal website that's used primarily for fun. I upload images, videos and text that I want to share. An HTML submission form accepts questions and string submissions from users, which uses ...
1
vote
0answers
25 views

Wrapper function that returns cached value from WinAPI call [closed]

I am writing myself a little wrapper and I decided to cache values that shouldn't change (often or at all) for returning to the user, I'm coming from the premise that the WinAPI call is more expensive ...
4
votes
1answer
374 views

TypeScript simple localStorage cache

I have a simple localStorage cache class written in TypeScript, would love to have some insights on any way/aspect you think it can be improved (making it more readable, maintainable, usable, etc.): <...
1
vote
1answer
244 views

TypeScript fetch wrapper class with localStorage cache

I'm learning TypeScript while doing my portfolio, and I wrote a class to make a fetch request to the API that holds my data. It is working fine. I use localStorage to set a cache to avoid calling the ...
2
votes
1answer
62 views

Update cache with minimal blocking

As part of the task, it is allowed to use slightly outdated data. It is required that only one thread per key is involved in the critical section, while the remaining threads use data from the cache ...
7
votes
1answer
401 views

Decorator to cache a function result for some time

I recently played around with a script that got some data from the Google API. As I didn't want to spam requests at the service (and potentially get blocked), I made this decorator, which caches the ...
2
votes
0answers
45 views

Parametrized cache simulation in C

This is an assignment known as a Cachelab from CMU 15-213. The full writeup for the lab can be found here, the handout I'm working against - here. All in all, the task is to emulate a cache, given the ...
2
votes
1answer
85 views

LRU Cache Example

Please check the following the LRU cache implementation. Thanks for the valuable comments ...
2
votes
1answer
56 views

Comparing two bash caches

I was working on making a cache in bash and I found this link - But this guy is attempting to generate new bash functions by introspecting their source and generating a new one as a cache. This seems ...
1
vote
1answer
44 views

Python-like decorators for caching

I am building an ad-hoc text-editor. I have two functions which use a cache, provideHover and provideCompletionItems. ...
2
votes
2answers
323 views

Simple c# MemoryCache mechanism to reduce number of db calls

I have some legacy code which gets a list of Students and their corresponding School. It's LinqToSql and there is no lazy ...
2
votes
0answers
83 views

Loading weak cache in typescript

In Java, I use a LoadingCache which offers weakKeys and I need something similar in Typescript, so I wrote the following: ...
4
votes
0answers
99 views

downloading a list of urls

I wrote this quick (lots of googling) and dirty (I hope not too dirty) script to download a URL list with a win32 wget port and save them as files with the url as the name to use as a "poor man's url ...
8
votes
1answer
636 views

Direct Mapped Cache simulation

This is my attempt to build a simple simulation of a direct mapped cache, I'm new to C and trying to learn some low level concepts. I had some difficulties with the design, because I'm used to program ...
2
votes
1answer
48 views

PHP - using static variables to store “client” for later use

I had this S3Helper class before such that, every time I called a function to any of its methods (which I haven't shown here, but which do things like upload files to s3 or get temporary s3 links), it ...
3
votes
1answer
78 views

Caching lookup values in an e-commerce website

I am working on an e-commerce website. I have a CarMake dropdown which contains car make names and their corresponding Id, for example: { 1:Alfa romeo}, { 2:Audi }, ...
1
vote
0answers
811 views

Fast matrix transpose

I would like to improve the naive matrix transpose algorithm by using a cache friendly algorithm. So far there are 4 variants. Iterate over the source matrix: ...
4
votes
2answers
116 views

Least Recently Used Cache Daily Coding Practice

I have the following challenge problem for which I was able to get a solution working, but not in \$O(1)\$ time as the problem asks for. Could someone point me in the right direction to optimize this?...
2
votes
1answer
384 views

Simple, flexible, and thread-safe key/value memory cache

MemoryCache.cs ...
7
votes
2answers
967 views

Wrapping IMemoryCache with SemaphoreSlim

I need simple caching for one of my web-services so I use the Microsoft.Extensions.Caching.Memory package. I wrapped it with ...
2
votes
0answers
311 views

localStorage should expire after 24 hours

The following code is checking if the user's browser is IE and if this is the case and there's no localStorage yet, it sets a localStorage, which should be valid for only 24 hours. ...
1
vote
1answer
136 views

Suppress API call in Redux Saga based on a timer

I have an API that provides data that is updated on an infrequent schedule, about once every 2½ minutes on average. Assuming that it's okay to fetch only as often as every 2½ minutes or less often, I'...
1
vote
0answers
74 views

Bookmark controller with IMemoryCache

I'm just doing a small hobby project to solve a little problem I have and I'm using it as a learning exercise for ASP.Net MVC 5, .Net Core 2 and Bootstrap. I'm using a nuget package that handles ...
2
votes
1answer
110 views

Using IndexedDB as an in-browser cache

In my site: Users have many Activities Each Activity has encoded_polyline data I display these encoded_polylines on a map I want to use IndexedDB (via Dexie) as an in-browser cache so that they don'...
2
votes
1answer
293 views

Cache with limited size; If full remove the oldest

Here is a class that stores a single value into the limited cache. If cache is full, it will remove the oldest element to make a space for a new value. I'm using 2 structures to accomplish this ...
5
votes
1answer
122 views

Data structure that is fast to read and modify

I'm working on an apllication that needs to process a lot of objects in realtime. I've separated the logic from the UI so that it isn't as much of a mess. The basic idea is that every tick I'm trying ...
6
votes
3answers
3k views

java Thread-safe LRUCache implementation

What is best way to implement thread-safe LRUCache in java? Please review this one. Is there any better approach which can be taken here? ...
3
votes
1answer
254 views

Rust closure to be called on a cache miss

The official Rust book chapter 13.1 includes an exercise to expand on the example provided in the chapter: Try modifying Cacher to hold a hash map rather than a single value. The keys of the hash map ...
3
votes
1answer
1k views

Cache-optimized matrix multiplication algorithm in C

I am trying to optimize matrix multiplication on a single processor by optimizing cache use. I am implemented a block multiplication and used some loop unrolling, but I'm at a loss on how to optimize ...
1
vote
1answer
56 views

When slide show web page is reopen, the web page loading is very slow

Here is a script that opens about 200 pictures, the first time you open the webpage, loading of the 200 pictures is fast, However if you reopen the page, it takes about 4 minutes to load the same page ...
3
votes
1answer
71 views

Reference service for a cache

I'm using JDK 11. This is my code: ...
3
votes
0answers
41 views

Caching different http-requests

There have been multiple discussions on caching http-requests with RXJS. In this question/proposal I want to propose a custom rxjs-operator (non-pure) to provide ...
3
votes
0answers
378 views

Iteration of self-refreshing MemoryCache encapsulation

I have attempted to implement the advice from the original post and debugged the original concept. Certain changes in the logic have necessitated other changes, including breaking into the library ...
2
votes
1answer
100 views

Long cache refresh with guaranteed response

I am trying to ensure that (once a cache item is populated) even if it's refresh object takes a long time to retrieve, the original cache item can be requested. ...
2
votes
1answer
63 views

Simple local cache that checks by date else get from db

I'm looking for feedback on how this can be improved. Basically what I'm trying to do is check if the cache has the object, else check from the database. I have a list of ids, then I separate them ...
2
votes
1answer
72 views

Generic Cache-Aware Data Adapter

I've written a generic data adapter that can make use of a cache, for use in a data access layer. It presents an interface allowing CRUD operations, as well as retrieving all objects of a certain type....
2
votes
1answer
593 views

LRU Cache in C++11

This is a simple and robust LRUCache implementation using doubly linked list and unordered map. It supports .get(), .put(), and <...

1
2 3 4 5 6