Giter Site home page Giter Site logo

cache-lib's Introduction

RuneTopic Cache Library

Discord

A cache library written in Kotlin.

Supported

  • RS2 (414-772)
  • RS3 (773-~788)
  • OSRS (1-current)

Features

  • Cache Reading
  • Definitions/Providers Loading
  • Very Fast (Limited by I/O)

TODO

  • Cache Writing
  • Flat File System
  • Ondemand Data Caching
  • 317 and older support
  • Tests

Implementation

Just use cache if you do not require any of the revision specific loaders.

cache = { module = "com.runetopic.cache:cache", version.ref "1.4.19-SNAPSHOT" }
loader = { module = "com.runetopic.cache:loader", version.ref "647.6.4-SNAPSHOT" }
//SNAPSHOTS
maven {
    url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

Usage

Index -> Group -> File

Creating a new JS5 store

val store = Js5Store(path = Path.of("/path/"), parallel = true)

Getting an index

val index = store.index(indexId = 5)

Getting a group by group id

val index = store.index(indexId = 5)
val group = index.group(groupId = 360)

Getting a group by group name

val index = store.index(indexId = 5)
val group = index.group(groupName = "m50_50")

Getting a file from a group by id

val index = store.index(indexId = 2)
val group = index.group(groupId = 26)
val file = group.file(fileId = 1000)

Looping multiple groups from an index

store.index(indexId = 19).use { index ->
    (0 until index.expand()).forEach {
        val data = index.group(it ushr 8).file(it and 0xFF).data
    }
}

Looping multiple files from a group

store.index(indexId = 2).group(groupId = 26).files().forEach {
    val id = it.id
    val data = it.data
}

Getting the reference table of an index and group by id.

val size = store.groupReferenceTable(indexId = 255, groupId = 255)

Getting an index reference table size by id

val size = store.indexReferenceTableSize(indexId = 28)

Getting a group reference table size by name

val size = store.groupReferenceTableSize(indexId = 30, groupName = "windows/x86/jaclib.dll")

Getting a group reference table size by id

val size = store.groupReferenceTableSize(indexId = 30, groupId = 6)

Getting 255, 255 checksums with RSA/Whirlpool

val checksums = store.checksumsWithRSA(exponent = BigInteger(""), modulus = BigInteger(""))

Getting 255, 255 checksums without RSA/Whirlpool

val checksums = store.checksumsWithoutRSA()

An example of a single thread loading providers

val objProvider = objs().load(store)
val npcProvider = npcs().load(store)
val locProvider = locs().load(store)
val particleProvider = particles().load(store)

An example of multiple threads parallel loading providers

val pool = Executors.newFixedThreadPool(4)
val providers = listOf(
    objs(),
    npcs(),
    locs(),
    particles()
)
val latch = CountDownLatch(providers.size)
providers.forEach {
    pool.execute {
        it.load(store)
        latch.countDown()
    }
}
latch.await()
pool.shutdown()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to write unit test and or update any test that might have been impacted.

cache-lib's People

Contributors

tyler27 avatar ultraviolet-jordan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.