Compare commits
2 commits
9fa252a6af
...
08ea09a347
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08ea09a347 | ||
|
|
879ab82cae |
3 changed files with 16 additions and 3 deletions
|
|
@ -1,20 +1,29 @@
|
||||||
use redis::AsyncCommands;
|
use redis::AsyncCommands;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
use tokio::sync::OnceCell;
|
||||||
|
|
||||||
/// Redis caching layer implementing the key patterns and TTLs
|
/// Redis caching layer implementing the key patterns and TTLs
|
||||||
/// defined in DATA_MODEL.md section 3.
|
/// defined in DATA_MODEL.md section 3.
|
||||||
pub struct CacheService {
|
pub struct CacheService {
|
||||||
client: redis::Client,
|
client: redis::Client,
|
||||||
|
conn: OnceCell<redis::aio::MultiplexedConnection>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CacheService {
|
impl CacheService {
|
||||||
pub fn new(redis_url: &str) -> Result<Self, redis::RedisError> {
|
pub fn new(redis_url: &str) -> Result<Self, redis::RedisError> {
|
||||||
let client = redis::Client::open(redis_url)?;
|
let client = redis::Client::open(redis_url)?;
|
||||||
Ok(Self { client })
|
Ok(Self {
|
||||||
|
client,
|
||||||
|
conn: OnceCell::new(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn conn(&self) -> Result<redis::aio::MultiplexedConnection, redis::RedisError> {
|
async fn conn(&self) -> Result<redis::aio::MultiplexedConnection, redis::RedisError> {
|
||||||
self.client.get_multiplexed_async_connection().await
|
let conn = self
|
||||||
|
.conn
|
||||||
|
.get_or_try_init(|| self.client.get_multiplexed_async_connection())
|
||||||
|
.await?;
|
||||||
|
Ok(conn.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Tile cache ──────────────────────────────────────────────
|
// ── Tile cache ──────────────────────────────────────────────
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!-- Disable Impeller/Vulkan — fallback to Skia/OpenGL for devices with poor Vulkan support -->
|
<!-- Disable Impeller/Vulkan — vector_map_tiles canvas ops are incompatible with Impeller -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="io.flutter.embedding.android.EnableImpeller"
|
android:name="io.flutter.embedding.android.EnableImpeller"
|
||||||
android:value="false" />
|
android:value="false" />
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ class _MapScreenState extends ConsumerState<MapScreen> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_mapController = MapController();
|
_mapController = MapController();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
ref.read(mapProvider.notifier).locateUser();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -50,6 +53,7 @@ class _MapScreenState extends ConsumerState<MapScreen> {
|
||||||
FlutterMap(
|
FlutterMap(
|
||||||
mapController: _mapController,
|
mapController: _mapController,
|
||||||
options: MapOptions(
|
options: MapOptions(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
initialCenter: mapState.center,
|
initialCenter: mapState.center,
|
||||||
initialZoom: mapState.zoom,
|
initialZoom: mapState.zoom,
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue