321 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
2k
views
How can I fix: _lruCache is not a constructor
I have dug myself into a hole. I have been chasing a bug for a while that I finally concluded today must be in my version of expo or react or react native. But that is another issue. So I started ...
-1
votes
1
answer
93
views
Circular dependency where two containers store iterators to each other's elememts
I wrote quick impl of LRU cache, where all the data (eg key -> value pairs) is stored in unordered map, and the order list simply stored pointers to these items.
if it was regular C data structs, ...
Pavel P's user avatar
- 17.3k
0
votes
1
answer
80
views
Python's functools.lru_cache and cache not caching results of class function
I want to use lru_cache (or cache, doesn't really matter) to store the results of a very computatively intensive function of a class. However, it does not work as intended as when I included a print ...
0
votes
1
answer
97
views
Can the pages obtained by get_user_pages() be directly recycled or swapped out without using put_user_pages()?
get_user_pages() increments the page reference count. And that is why it can pin the page in memory.
So I wonder whether the pages obtained by get_user_pages() can be directly recycled or swapped out ...
3
votes
1
answer
167
views
Why prefer DoubleLinkedList instead of queue and hashmap to design Least recently used (LRU)?
I am solving leetcode LRU design problem - Leetcode LRU:
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
Implement the LRUCache class:
LRUCache(int ...
0
votes
0
answers
315
views
Deque vs list for LRU Cache Implementation
I was trying to implement LRU Cache for a Leetcode question. My final code is below and it works fine. However, my first choice was deque instead of list with exactly same procedure and I was getting ...
0
votes
1
answer
60
views
Number of hits in fibonacci using lru_cache
I am using functools.lru_cache to implement Fibonacci using memoization. But I do not understand the number of hits that my output generates. My code is as follows:
@lru_cache(maxsize=8)
def fib(n):
...
0
votes
1
answer
45
views
Caching : functools vs API Gateway
I have a lambda function which is an api fetching data from the database. I want to add caching to the method itself, with the idea that if the lambda is being invoked it should return the cached ...
0
votes
1
answer
43
views
double value contains 'm' at the end while printing in google benchmarks table
This is my Benchmark method.
static void BM_LRU(benchmark::State &state) {
lru_cache* cache = lru_init(state.range(0));
std::vector<int> pages = generateRandomPages(state.range(1));
...
4
votes
3
answers
204
views
Ordering is not correct in TreeSet
I'm trying to solve https://leetcode.com/problems/lru-cache/description/.
I'm using treeset to save unique keys and order them based on when it's inserted. The treeset is not returning elements in the ...
0
votes
1
answer
101
views
Why doesn't this implementation of LRU cache work?
I encountered this problem on LeetCode, which needs us to implement the LRU cache functions "get" and "put" in O(1) average time complexity.
I tried the similar method here, in ...
0
votes
1
answer
64
views
How to properly cache reads from a sql query if it's possible the sql table can be mutated between reads with the same input
I'm trying to figure out the most robust caching scheme for my particular use case.
I have a class that matches temporal data. The data is on a per day granularity (there's no intraday data).
class ...
1
vote
1
answer
93
views
Number of hits in Fibonacci using dynamic programming
I am using functools.lru_cache to implement Fibonacci using memoization. But I do not understand the number of hits that my output generates. My code is as follows:
@lru_cache(maxsize=8)
def fib(n):
...
0
votes
0
answers
101
views
How to check whether an iterator is uninitialized in C++? or compare an iterator against NULL?
I was implementing LRU Cache in C++.
Here is what the class looks like,
class LRUCache {
private:
int capacity;
list<pair<int,int>> memory; // key,value
...
0
votes
1
answer
181
views
Vert.x SharedData - can it reliably store an LRU?
I'm trying to store a list of things in the Vert.x cluster shared data, where the list if kind of like a queue, but things drop off of the queue based on a limit of number of elements - basically the ...