Mercurial Hosting > chat
comparison src/lib/Db.luan @ 2:ee1f91e67509
add Db
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 24 Oct 2024 15:37:35 -0600 |
| parents | |
| children | 2da10ece826f |
comparison
equal
deleted
inserted
replaced
| 1:b116b6ef07bf | 2:ee1f91e67509 |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | |
| 2 local error = Luan.error | |
| 3 local new_error = Luan.new_error or error() | |
| 4 local Lucene = require "luan:lucene/Lucene.luan" | |
| 5 local Io = require "luan:Io.luan" | |
| 6 local uri = Io.uri or error() | |
| 7 local Http = require "luan:http/Http.luan" | |
| 8 local Thread = require "luan:Thread.luan" | |
| 9 local Time = require "luan:Time.luan" | |
| 10 local Logging = require "luan:logging/Logging.luan" | |
| 11 local logger = Logging.logger "Db" | |
| 12 | |
| 13 | |
| 14 local dir = uri("site:/private/local/lucene") | |
| 15 | |
| 16 local Db = Lucene.index( dir, { | |
| 17 log_dir = uri("site:/private/local/lucene_log") | |
| 18 name = "lucene" | |
| 19 version = 1 | |
| 20 } ) | |
| 21 | |
| 22 Db.indexed_fields.user_email = Lucene.type.lowercase | |
| 23 | |
| 24 function Db.not_in_transaction() | |
| 25 logger.error(new_error("not in transaction")) | |
| 26 end | |
| 27 | |
| 28 Db.update{ | |
| 29 } | |
| 30 | |
| 31 if Http.is_serving then | |
| 32 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } ) | |
| 33 end | |
| 34 | |
| 35 return Db |
