| 1 |
package website.tasks; |
| 2 |
|
| 3 |
import ufront.tasks.UFTaskSet; |
| 4 |
import ufront.cache.DBCache; |
| 5 |
import ufront.cache.RequestCacheMiddleware; |
| 6 |
import website.api.ProjectApi; |
| 7 |
|
| 8 |
class HaxelibCacheTasks extends UFTaskSet { |
| 9 |
@:skip @inject public var api:DBCacheApi; |
| 10 |
|
| 11 |
/** Set up the cache table. **/ |
| 12 |
public function setup():Void api.setup(); |
| 13 |
|
| 14 |
/** Clear every cached item. **/ |
| 15 |
public function clearAll():Void api.clearAll(); |
| 16 |
|
| 17 |
/** Clear all cached pages. **/ |
| 18 |
public function clearPageCache() api.clearNamespace( RequestCacheMiddleware.namespace ); |
| 19 |
|
| 20 |
/** Clear a projects zip file cache entries, and also the page caches for that project. **/ |
| 21 |
public function clearZipCache( project:String, version:String ) { |
| 22 |
var namespaces = ProjectApi.cacheNames; |
| 23 |
var prefix = '$project:$version:%'; |
| 24 |
api.clearItemLike( namespaces.info, prefix ); |
| 25 |
api.clearItemLike( namespaces.dirListing, prefix ); |
| 26 |
api.clearItemLike( namespaces.fileBytes, prefix ); |
| 27 |
api.clearItemLike( RequestCacheMiddleware.namespace, '/p/$project/%' ); |
| 28 |
} |
| 29 |
} |