Jump to content

Recommended Posts

Posted (edited)

Hello there!

 

Let's go straight in the topic!

I want to implement an lru cache for educational purposes.

The main LRU cache class will implement an interface which contains the following methods :

Note : V and K are generic references

 

  • V lookUp(K key) : returns the value V with K as its key 
  • void store(V value, K key) : obviously stores the data in the cache 
  • double getHitRatio() 
  • long getNumberOfLookups() 
  • long getNumberOfhits() 
  • long getNumberOfMisses()

 

Sooooo right now i have an alpha implementation implemented as following :

I use a hashmap which i implement (NOTE : i wanna implement each data structure im gonna use by myself)

to store the values, and a queue where i insert the keys.

Each time an item is inserted, i check the size of the queue.

If queue.size() > cacheSize, i pop() all the expired keys and remove their values from the map

 

So after testing it with Strings and 50k entries input i get the freaking huge time of 17seconds!!!!!!! and a hit ratio of 9%(!)

If i remove the removal of the expired keys the time drops to 1 sec and the hit ratio goes to 98%,but the application isnt an lru cahce implementation.....

 

Another implementation suggested by a friend was to use splay trees, cause the least recently used nodes would be near the root.

I also thought to try and implement B Trees , but i aint so fond of it

 

So , what do you guys suggest?

Which data structures should i use for this "project"?

If i need to use a hashmap , is linear probing the type of hash that would fit, since there are no memory issues?

 

Thanks in advance for your help guys,

Regards FelonBIG

Edited by FelonBIG
  • 2 months later...
Posted

well since it's outdated you can lock it.

Also i finished an alpha version of this project which i can share for the community if someone's interested.

Guest
This topic is now closed to further replies.


  • Posts

    • ➡ Discount for your purchase: APRIL (10% discount) ➡ Our Online Shop: https://socnet.store ✅ ➡ Our SMM-Boosting Panel: https://socnet.pro ✅ ➡ Telegram Shop Bot: https://socnet.shop ✅ ➡ Telegram Support: https://t.me/solomon_bog ✅ ➡ Telegram Channel: https://t.me/accsforyou_shop ✅ ➡ Discord Support: @AllSocialNetworksShop ✅ ➡ Discord Server: https://discord.gg/y9AStFFsrh ✅ ➡ WhatsApp Support: https://wa.me/79051904467✅ ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n ✅ ➡ Email Support: solomonbog@socnet.store ✅
    • ➡ Discount for your purchase: APRIL (10% discount) ➡ Our Online Shop: https://socnet.store ✅ ➡ Our SMM-Boosting Panel: https://socnet.pro ✅ ➡ Telegram Shop Bot: https://socnet.shop ✅ ➡ Telegram Support: https://t.me/solomon_bog ✅ ➡ Telegram Channel: https://t.me/accsforyou_shop ✅ ➡ Discord Support: @AllSocialNetworksShop ✅ ➡ Discord Server: https://discord.gg/y9AStFFsrh ✅ ➡ WhatsApp Support: https://wa.me/79051904467✅ ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n ✅ ➡ Email Support: solomonbog@socnet.store ✅
    • Hey. I've been looking all over the internet about this but not being able to find anything about it. I have edited systemmsg using MSG editor changing colors etc. But now I want to change and add some of the sounds as well. But I need the sound IDs for each audiofile and I dont know how to find them. Ive found all the audio files but I cant use the filename as someone said in a thread here, it only seem to take numbers. I have looked into every guide about systemmsg on this website and no one mention anything about the sound, just that its possible to add sound but nothing more. So, do anyone know how to find these sound IDs? Preferably together with the soundname of the audio file that it plays so I know which ID to use for each soundfile. Thanks in advance!
    • We are certainly not an ambulance, but we will definitely cure you of blacklists and empty pockets. Live freely with SX! Each of you will receive a trial version of SX to familiarize yourself with the product, all you have to do is post in this thread
  • Topics

×
×
  • Create New...