summaryrefslogtreecommitdiffabout
path: root/cgit.h
authorLars Hjemli <hjemli@gmail.com>2006-12-10 21:31:36 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-10 21:31:36 (UTC)
commit25105d7ecaba474d4b7c364ebb586aac3dfc5abb (patch) (side-by-side diff)
tree8beb08db1399b8efb8c7fbcd936044ae7fc232e6 /cgit.h
parent856c026e221d8ed82c5b75bc8da4bd65e89ea953 (diff)
downloadcgit-25105d7ecaba474d4b7c364ebb586aac3dfc5abb.zip
cgit-25105d7ecaba474d4b7c364ebb586aac3dfc5abb.tar.gz
cgit-25105d7ecaba474d4b7c364ebb586aac3dfc5abb.tar.bz2
Add caching infrastructure
This enables internal caching of page output. Page requests are split into four groups: 1) repo listing (front page) 2) repo summary 3) repo pages w/symbolic references in query string 4) repo pages w/constant sha1's in query string Each group has a TTL specified in minutes. When a page is requested, a cached filename is stat(2)'ed and st_mtime is compared to time(2). If TTL has expired (or the file didn't exist), the cached file is regenerated. When generating a cached file, locking is used to avoid parallell processing of the request. If multiple processes tries to aquire the same lock, the ones who fail to get the lock serves the (expired) cached file. If the cached file don't exist, the process instead calls sched_yield(2) before restarting the request processing. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'cgit.h') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h47
1 files changed, 45 insertions, 2 deletions
diff --git a/cgit.h b/cgit.h
index 19f7ba7..1e084d4 100644
--- a/cgit.h
+++ b/cgit.h
@@ -1,21 +1,64 @@
#ifndef CGIT_H
#define CGIT_H
#include "git.h"
#include <openssl/sha.h>
+#include <ctype.h>
+#include <sched.h>
+
+typedef void (*configfn)(const char *name, const char *value);
+
+struct cacheitem {
+ char *name;
+ struct stat st;
+ int ttl;
+ int fd;
+};
+
+extern char *cgit_root;
+extern char *cgit_root_title;
+extern char *cgit_css;
+extern char *cgit_logo;
+extern char *cgit_logo_link;
+extern char *cgit_virtual_root;
+extern char *cgit_cache_root;
+
+extern int cgit_cache_root_ttl;
+extern int cgit_cache_repo_ttl;
+extern int cgit_cache_dynamic_ttl;
+extern int cgit_cache_static_ttl;
+extern int cgit_cache_max_create_time;
+
+extern char *cgit_repo_name;
+extern char *cgit_repo_desc;
+extern char *cgit_repo_owner;
+
+extern int cgit_query_has_symref;
+extern int cgit_query_has_sha1;
+
+extern char *cgit_querystring;
+extern char *cgit_query_repo;
+extern char *cgit_query_page;
+extern char *cgit_query_head;
+extern char *cgit_query_sha1;
+
+extern int htmlfd;
extern char *fmt(const char *format,...);
extern void html(const char *txt);
extern void htmlf(const char *format,...);
extern void html_txt(char *txt);
extern void html_attr(char *txt);
-
extern void html_link_open(char *url, char *title, char *class);
extern void html_link_close(void);
-typedef void (*configfn)(const char *name, const char *value);
extern int cgit_read_config(const char *filename, configfn fn);
+extern int cache_lookup(struct cacheitem *item);
+extern int cache_lock(struct cacheitem *item);
+extern int cache_unlock(struct cacheitem *item);
+extern int cache_expired(struct cacheitem *item);
+
#endif /* CGIT_H */