Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cache]

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

0
votes
1answer
26 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
24 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
52 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
109 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 ...
1
vote
0answers
74 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 ...
3
votes
2answers
178 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? ...
2
votes
1answer
69 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 ...
3
votes
1answer
97 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
50 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
65 views

Reference service for a cache

I'm using JDK 11. This is my code: ...
2
votes
0answers
30 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
82 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
56 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. ...
1
vote
1answer
52 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
57 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
195 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
vote
1answer
69 views

Minimum steps to reach target by a Knight In Scala

Given a chessboard of N size (square matrix), the position of Knight and position of a target, find out minimum steps (both count and exact steps) from start to target for a Knight. If it is not ...
2
votes
0answers
51 views

Implementing key map with expire and size limit

Recently I have been asked to implement a key map with expire time for each key and possibility to limit the number of keys, in Python. I've used a dictionary + heap to store the entries, e.g.: ...
1
vote
0answers
47 views

Design a system for renting digital movies/books

During an interview I was asked to do an OO design for a digital renting system for books/movies. This is the design that I came up with. My assumptions: When the customer has downloaded a list of ...
2
votes
1answer
162 views

Leetcode #146. LRUCache solution in Java (Doubly Linked List + HashMap)

Problem Statement Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
0
votes
0answers
42 views

Using ReadWriteLock to implement a cache access guard

In my project, there is an internal cache api to use. I have noticed an emerging pattern such that: ...
2
votes
2answers
224 views

Simple implementation of LRU caching in PHP

This is my implementation of LRU caching in PHP. It works fine when I tested as. What are the things that I miss or need attention? ...
1
vote
2answers
93 views

DataService that fetches data not loaded already or loads cached values

I load an array from an API that is available throughout the user's whole session. This data is unlikely to change, so it can be cached safely. I have a DataService ...
0
votes
2answers
679 views

LRU Cache in constant time

I would like to ask for code review for my LRU Cache implementation from leetcode. Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following ...
6
votes
0answers
95 views

Resource cache based on Stroustrup 22.2.4

I recently read "The C++ programming language" chapter 22 and I thought the example given in chapter 22.2.4 was quite interesting. I thought it should be possible to make this system caching, so it ...
4
votes
2answers
300 views

Thread-safe cache using a linked list

Are the final templated functions allocate and deallocate thread safe? The Cache object is a ...
4
votes
2answers
155 views

Fetching data through HTTP and caching JSON result in a file

The task is to fetch some JSON data from an API with a GET request. If the location is not available for any reason, read a cache file. Otherwise write the cache file for future use. The following ...
3
votes
1answer
106 views

Custom caching class in Swift

I'm using Swift 4.0 and I'm using UserDefaults in my project for storing Strings like login or something. I have a class: ...
2
votes
2answers
153 views

C++ Software cache for shared resources

I wrote a basic C++ template to manage shared resources like textures and shaders in a 3D engine. The idea is that the cache itself holds weak references to the resources (through ...
2
votes
1answer
90 views

Least recent use cache in python

Below is LRU Cache class implementation. ...
0
votes
1answer
60 views

Maintaining a temporary directory

I have this class/service, which I need to maintain. Its purpose is to manage a temporary directory so that all content can be deleted on next restart files are not left behind when you're done with ...
1
vote
1answer
319 views

Cached Repository that can refresh all or a subset of the data

IReadOnlyCachedRepository<T> ...
6
votes
1answer
107 views

Simple time-bound cache

In my project i should cache some items (1 - 1000) in one time. Item should be removed from cache after 5 minutes by last access to cached item. Better use community libs, or standart mechanisms (...
4
votes
3answers
838 views

Thread-safe LRU cache

Please review my code. I am trying to implement a thread-safe LRU cache using std::list and std::unordered_map. This is a header-...
3
votes
1answer
1k views

Memory cache implementation with a static class inside a normal class

I'm trying to implement a cache available in a data provider (repository). The data provider is a normal class, instanciated at every request made to the application. The reason I have a static ...
11
votes
3answers
2k views

Implementation of LRU cache

What do you think of this implementation of an LRU cache? I'm trying to migrate to modern C++, so it would be fantastic if you could give me any tips here. I've heard it's not desired to use raw ...
4
votes
3answers
165 views

Caching an integer - distinguishing no value from zero

I would like to store an integer value in the application cache. The GetOrSet method should always return an int, and never be null. If there is no cached value, ...
1
vote
1answer
1k views

Changing object attributes by calling getters and setters using reflection

We have a class with 10 attributes (longs, Strings) the following method should change any attribute to any value of an object specified by the client, It mimics the SQL update statement ...
0
votes
2answers
101 views

Create another Singleton object from a Singleton class

I want to create a singleton object of a third party caching library (ThirdPartyKVStore). But I don't want to reference this class all over the place from where I ...
2
votes
1answer
142 views

Stack for asynchronous processing

The following TaskStack processes input elements asynchronously based on a function that it receives at construction: ...
3
votes
1answer
77 views

Speeding up evaluation of power series, Python

I want to plot (on the complex plane, with mpmath) the power series whose general term is the number of partitions of an integer. The more points I want (and the ...
2
votes
2answers
422 views

Simple yet threadsafe file cache in java

I'm attempting to cache contents of a file to avoid frequent reads, using a very simple implementation in a single class. The file contains a list of emailids, one per line. The file changes rarely, ...
4
votes
1answer
189 views

Cache friendly string

Suppose you have a vector or list from the following: struct Data{ std::string key; //... }; When you do some processing, when you compare the key, it ...
1
vote
0answers
115 views

Service Worker fetch handler with promise race code

Some combinations of older hard drives, virus scanners, and faster internet connections, getting resources from the network can be quicker than cached content on the user's disk. Looking for a way ...
-1
votes
1answer
856 views

C# implementation of LRU-cache

I implemented a LRU-cache in C# and wanted to hear suggestions in making it more readable and maybe even more compact. ...
11
votes
2answers
5k views

LRU cache implementation

I have implemented an LRU cache, the question is taken from: leetcode: 146. LRU Cache Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following ...
1
vote
1answer
916 views

CacheManager - Dependency injection

I create a cache manager to manage a system of cache exchangeable by another implementation. I use the CacheManager class throughout my program. If I want to ...
3
votes
1answer
3k views

LRU cache implementation in C++ using unordered_map and doubly linked list

I have implemented an LRU cache in C++ using a hash table and a doubly linked list. Any kind of feedback is appreciated. ...
4
votes
1answer
575 views

Sequence cache with TTL expiry

I've had some fun writing a sequence based cache that is going to be used to maintain a consistent stream withstanding network re-connections. The idea is that subscribers of a network based stream ...
4
votes
2answers
4k views

Rest API for realtime statistics of last 60 seconds

The following code is my solution to a code challenge I submitted a few weeks ago. I got rejected straight away with no feedback and I've wondering why. I'm interested in hearing if there is any ...