• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / pg_jsonschema / 30734936653

02 Aug 2026 05:54AM UTC coverage: 1.046% (-97.9%) from 98.943%
30734936653

Pull #102

github

web-flow
Merge aa3c56f59 into a5a6306e3
Pull Request #102: chore: bump pgrx version to 0.19.2

5 of 478 relevant lines covered (1.05%)

0.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/compiled/cache.rs
1
/// Backend-local LRU cache mapping canonical schema strings to compiled validators.
2
///
3
/// PostgreSQL backends are single-threaded OS processes, so a `thread_local`
4
/// `RefCell` is sufficient — no mutex needed.
5
use std::cell::RefCell;
6
use std::num::NonZeroUsize;
7
use std::sync::Arc;
8

9
type Cache = lru::LruCache<String, Arc<jsonschema::Validator>>;
10

11
const CAPACITY: NonZeroUsize = NonZeroUsize::new(128).expect("128 is non zero");
12

13
thread_local! {
14
    static CACHE: RefCell<Cache> = RefCell::new(lru::LruCache::new(CAPACITY));
15
}
16

17
/// Returns the cached validator for `schema`, inserting one produced by `f` on a miss.
18
pub(super) fn get_or_insert(
×
19
    schema: &str,
×
20
    f: impl FnOnce() -> Arc<jsonschema::Validator>,
×
21
) -> Arc<jsonschema::Validator> {
×
22
    CACHE.with_borrow_mut(|c| {
×
23
        if let Some(v) = c.get(schema) {
×
24
            return Arc::clone(v);
×
25
        }
×
26
        let validator = f();
×
27
        c.put(schema.to_owned(), Arc::clone(&validator));
×
28
        validator
×
29
    })
×
30
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc