Add CacheProvider

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 3 years ago
parent 6a0266e88f
commit 1b83f4b4b3
  1. 6
      game/src/main/kotlin/org/openrs2/game/GameModule.kt
  2. 16
      game/src/main/kotlin/org/openrs2/game/cache/CacheProvider.kt

@ -5,10 +5,12 @@ import com.google.inject.AbstractModule
import com.google.inject.Scopes
import com.google.inject.multibindings.Multibinder
import org.openrs2.buffer.BufferModule
import org.openrs2.cache.Cache
import org.openrs2.cache.CacheModule
import org.openrs2.cache.Js5MasterIndex
import org.openrs2.cache.Store
import org.openrs2.conf.ConfigModule
import org.openrs2.game.cache.CacheProvider
import org.openrs2.game.cache.Js5MasterIndexProvider
import org.openrs2.game.cache.StoreProvider
import org.openrs2.game.net.NetworkService
@ -34,5 +36,9 @@ public object GameModule : AbstractModule() {
bind(Js5MasterIndex::class.java)
.toProvider(Js5MasterIndexProvider::class.java)
.`in`(Scopes.SINGLETON)
bind(Cache::class.java)
.toProvider(CacheProvider::class.java)
.`in`(Scopes.SINGLETON)
}
}

@ -0,0 +1,16 @@
package org.openrs2.game.cache
import io.netty.buffer.ByteBufAllocator
import org.openrs2.cache.Cache
import org.openrs2.cache.Store
import javax.inject.Inject
import javax.inject.Provider
public class CacheProvider @Inject constructor(
private val store: Store,
private val alloc: ByteBufAllocator
) : Provider<Cache> {
override fun get(): Cache {
return Cache.open(store, alloc)
}
}
Loading…
Cancel
Save