feat: database as plugin
This commit is contained in:
16
readme.md
16
readme.md
@@ -28,7 +28,7 @@ Start proxy server.
|
||||
| `--cache-ttl <timeout>` | `CACHE_TTL` | `3600` | Cache expiration timeout in seconds |
|
||||
| `--redis-address <address>` | `REDIS_ADDRESS` | `http://localhost:6379` | Redis address |
|
||||
| `--redis-database <database>` | `REDIS_DATABASE` | `0` | Redis database |
|
||||
| `--redis-password <password>` | `REDIS_PASSWORD` | - | Redis password |
|
||||
| `--redis-password <password>` | `REDIS_PASSWORD` | - | Redis password |
|
||||
| `--redis-prefix <prefix>` | `REDIS_PREFIX` | `ncp-` | Redis keys prefix |
|
||||
|
||||
### `ncp list`
|
||||
@@ -54,16 +54,16 @@ import (
|
||||
|
||||
func main() {
|
||||
proxy := npmproxy.Proxy{
|
||||
RedisClient: redis.NewClient(&redis.Options{
|
||||
Addr: "localhost:6379",
|
||||
DB: 0,
|
||||
Password: "",
|
||||
}),
|
||||
Database: npmproxy.DatabaseRedis{
|
||||
Client: redis.NewClient(&redis.Options{
|
||||
Addr: "localhost:6379",
|
||||
}),
|
||||
},
|
||||
HttpClient: &http.Client{},
|
||||
GetOptions: func() (npmproxy.Options, error) {
|
||||
return npmproxy.Options{
|
||||
RedisPrefix: "ncp-",
|
||||
RedisExpireTimeout: 1 * time.Hour,
|
||||
DatabasePrefix: "ncp-",
|
||||
DatabaseExpiration: 1 * time.Hour,
|
||||
UpstreamAddress: "https://registry.npmjs.org",
|
||||
}, nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user