     }
     
     var db: Connection
-    
+    var t2icache: LRUCache<Term, TermID>
+    var i2tcache: LRUCache<TermID, Term>
+
     public init(filename: String, initialize: Bool = false) throws {
         db = try Connection(filename)
+        i2tcache = LRUCache(capacity: 1024)
+        t2icache = LRUCache(capacity: 1024)
         if initialize {
             try initializeTables()
         }

//                print("------------")
                return nil
            }
            return row[idColumn]
        } catch {}
        return nil
    }
    
    internal func term(for id: TermID) -> Term? {
        let query = termsTable.select(termsTable[*]).filter(idColumn == id)
        do {
            guard let row = try db.pluck(query) else {

                    guard let lang = row[termLangColumn] else {
                        return nil
                    }
                    let t = Term(value: value, type: .language(lang))
                    i2tcache[id] = t
                    return t
                } else {
                    let t = Term(value: value, type: .datatype(TermDataType(stringLiteral: dt)))
                    i2tcache[id] = t
                    return t
                }
            }
        } catch {}
