load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("fbcode_entropy_wardens_folly")

cpp_library(
    name = "file",
    srcs = [
        "FilePersistenceLayer.cpp",
    ],
    headers = [
        "FilePersistenceLayer.h",
        "FilePersistentCache.h",
    ],
    exported_deps = [
        ":lru_persistent_cache",
        "//folly:file_util",
        "//folly:memory",
        "//folly:scope_guard",
        "//folly/json:dynamic",
        "//folly/portability:unistd",
    ],
)

cpp_library(
    name = "lru_in_memory_cache",
    headers = [
        "LRUInMemoryCache.h",
        "LRUInMemoryCache-inl.h",
    ],
    exported_deps = [
        ":persistent_cache_common",
        "//folly:likely",
        "//folly:optional",
        "//folly/container:evicting_cache_map",
        "//folly/json:dynamic",
        "//folly/synchronization:lock",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "lru_persistent_cache",
    headers = [
        "LRUPersistentCache.h",
        "LRUPersistentCache-inl.h",
    ],
    exported_deps = [
        ":lru_in_memory_cache",
        ":persistent_cache",
        ":persistent_cache_common",
        "//folly:executor",
        "//folly:file_util",
        "//folly:scope_guard",
        "//folly/json:dynamic",
        "//folly/portability:sys_time",
        "//folly/synchronization:lock",
        "//folly/synchronization:saturating_semaphore",
        "//folly/system:thread_name",
    ],
)

cpp_library(
    name = "persistent_cache",
    headers = ["PersistentCache.h"],
    exported_deps = [
        "//folly:optional",
    ],
)

cpp_library(
    name = "persistent_cache_common",
    srcs = [
        "PersistentCacheCommon.cpp",
    ],
    headers = ["PersistentCacheCommon.h"],
    exported_deps = [
        "//folly:executor",
        "//folly:optional",
    ],
)
