Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
18 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
61 views

Reference service for a cache

I'm using JDK 11. This is my code: ...
1
vote
0answers
23 views

rxjs: 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 caching: ...
3
votes
0answers
67 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
45 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
40 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
71 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 <...
0
votes
1answer
47 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
39 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
38 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
104 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
34 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
121 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
86 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
325 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
61 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
208 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
103 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
78 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
114 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
58 views

Least recent use cache in python

Below is LRU Cache class implementation. ...
0
votes
1answer
56 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
195 views

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

IReadOnlyCachedRepository<T> ...
6
votes
1answer
92 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 (...
0
votes
0answers
236 views

Concurrency-safe cache in Go

I'm writing a concurrency-safe memo: ...
4
votes
3answers
597 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
775 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
150 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
910 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
94 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
125 views

Stack for asynchronous processing

The following TaskStack processes input elements asynchronously based on a function that it receives at construction: ...
3
votes
1answer
71 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
329 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, ...
3
votes
1answer
154 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
88 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
703 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. ...
8
votes
2answers
3k 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
704 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
2k 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
442 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
3k 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 ...
4
votes
2answers
91 views

C daemon to perpetually cache data from an external API

Background My task is to create a program to continuously download utility meter data from an external API, and cache it in a MySQL database for faster access. The performance of this program is ...
9
votes
2answers
723 views

Memoizing or caching Bash function results

Update: I've implemented several of the features suggested below and packaged the improved code into a dedicated project: bash-cache . I display a number of expensive operations in my Bash prompt (e....
3
votes
2answers
133 views

ConcurrentHashQueue in C#

The ConcurrentHashQueue data structure is a FIFO queue that at the same time allows look-ups of items based on a key in O(1) like a dictionary. It can be used as a ...
14
votes
5answers
4k views

Simple generic cache

I sometimes write decorators to cache results I get from a repository or I write other caches... I don't want to write another cache anymore. I'd like to have something that'll work for anything. I've ...
3
votes
1answer
595 views

JSON Cache Program

I have some code that is intended to be a package (so that it can be accessed via import cachejson). Here is the code for the package: The update variable is ...
6
votes
1answer
353 views

My lru_cache implementation

This code is intended to function exactly like functools.lru_cache. Is there anything I could improve in design, implementation, style, or any other area? (Python ...
0
votes
1answer
85 views

PHP Cache weather in a file

I'm using the darksky api to get weather data for a display board website. The free version is limited to 1000 api calls per month. I have a lot of devices (iPads) displaying this information in ...
3
votes
1answer
90 views

Validate iTunes links

I'm working on this code and I can't find a better way to improve this code, can anyone improve it more? My PHP is pretty bad, this is the best I could do. The code checks if iTunes link exists in ...