package com.fieldlabel.collector.data.local

import androidx.room.*

@Dao
interface GeocodeCacheDao {

    @Query("SELECT * FROM geocode_cache WHERE `key` = :key")
    suspend fun get(key: String): GeocodeCacheEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(entity: GeocodeCacheEntity)

    /** 30日以上経過したキャッシュを削除 */
    @Query("DELETE FROM geocode_cache WHERE cachedAt < :threshold")
    suspend fun evictOld(threshold: Long)
}
