Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
73be4bb7
Commit
73be4bb7
authored
1 year ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Probleme mit dem Redis-Cache in Stud.IP"
Closes #3513 Merge request
studip/studip!2400
parent
1d1f846c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/classes/StudipRedisCache.class.php
+11
-3
11 additions, 3 deletions
lib/classes/StudipRedisCache.class.php
resources/vue/components/RedisCacheConfig.vue
+11
-2
11 additions, 2 deletions
resources/vue/components/RedisCacheConfig.vue
with
22 additions
and
5 deletions
lib/classes/StudipRedisCache.class.php
+
11
−
3
View file @
73be4bb7
...
@@ -27,8 +27,9 @@ class StudipRedisCache implements StudipCache
...
@@ -27,8 +27,9 @@ class StudipRedisCache implements StudipCache
*
*
* @param string $hostname Hostname of redis server
* @param string $hostname Hostname of redis server
* @param int $port Port of redis server
* @param int $port Port of redis server
* @param string $auth Optional auth token/password
*/
*/
public
function
__construct
(
$hostname
,
$port
)
public
function
__construct
(
$hostname
,
$port
,
string
$auth
=
''
)
{
{
if
(
!
extension_loaded
(
'redis'
))
{
if
(
!
extension_loaded
(
'redis'
))
{
throw
new
Exception
(
'Redis extension missing.'
);
throw
new
Exception
(
'Redis extension missing.'
);
...
@@ -40,6 +41,10 @@ class StudipRedisCache implements StudipCache
...
@@ -40,6 +41,10 @@ class StudipRedisCache implements StudipCache
if
(
!
$status
)
{
if
(
!
$status
)
{
throw
new
Exception
(
'Could not add cache.'
);
throw
new
Exception
(
'Could not add cache.'
);
}
}
if
(
$auth
!==
''
)
{
$this
->
redis
->
auth
(
$auth
);
}
}
}
/**
/**
...
@@ -83,7 +88,10 @@ class StudipRedisCache implements StudipCache
...
@@ -83,7 +88,10 @@ class StudipRedisCache implements StudipCache
public
function
read
(
$arg
)
public
function
read
(
$arg
)
{
{
$key
=
$this
->
getCacheKey
(
$arg
);
$key
=
$this
->
getCacheKey
(
$arg
);
return
$this
->
redis
->
get
(
$key
);
$result
=
$this
->
redis
->
get
(
$key
);
return
(
$result
===
null
)
?
null
:
unserialize
(
$result
);
}
}
/**
/**
...
@@ -97,7 +105,7 @@ class StudipRedisCache implements StudipCache
...
@@ -97,7 +105,7 @@ class StudipRedisCache implements StudipCache
public
function
write
(
$name
,
$content
,
$expire
=
self
::
DEFAULT_EXPIRATION
)
public
function
write
(
$name
,
$content
,
$expire
=
self
::
DEFAULT_EXPIRATION
)
{
{
$key
=
$this
->
getCacheKey
(
$name
);
$key
=
$this
->
getCacheKey
(
$name
);
return
$this
->
redis
->
setEx
(
$key
,
$expire
,
$content
);
return
$this
->
redis
->
setEx
(
$key
,
$expire
,
serialize
(
$content
)
)
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
resources/vue/components/RedisCacheConfig.vue
+
11
−
2
View file @
73be4bb7
...
@@ -2,16 +2,20 @@
...
@@ -2,16 +2,20 @@
<div>
<div>
<label
class=
"col-4"
>
<label
class=
"col-4"
>
<span
class=
"required"
>
<span
class=
"required"
>
<translate>
Hostname
</translate>
{{
$gettext
(
'
Hostname
'
)
}}
</span>
</span>
<input
required
type=
"text"
name=
"hostname"
placeholder=
"localhost"
v-model=
"theHostname"
>
<input
required
type=
"text"
name=
"hostname"
placeholder=
"localhost"
v-model=
"theHostname"
>
</label>
</label>
<label
class=
"col-2"
>
<label
class=
"col-2"
>
<span
class=
"required"
>
<span
class=
"required"
>
<translate>
Port
</translate>
{{
$gettext
(
'
Port
'
)
}}
</span>
</span>
<input
required
type=
"text"
name=
"port"
placeholder=
"6379"
v-model=
"thePort"
>
<input
required
type=
"text"
name=
"port"
placeholder=
"6379"
v-model=
"thePort"
>
</label>
</label>
<label>
{{
$gettext
(
'
Passwort/Token zur Authentifizierung
'
)
}}
<input
type=
"text"
name=
"auth"
v-model=
"theAuth"
>
</label>
</div>
</div>
</
template
>
</
template
>
...
@@ -26,12 +30,17 @@ export default {
...
@@ -26,12 +30,17 @@ export default {
port
:
{
port
:
{
type
:
Number
,
type
:
Number
,
default
:
6379
default
:
6379
},
auth
:
{
type
:
String
,
default
:
''
}
}
},
},
data
()
{
data
()
{
return
{
return
{
theHostname
:
this
.
hostname
,
theHostname
:
this
.
hostname
,
thePort
:
this
.
port
,
thePort
:
this
.
port
,
theAuth
:
this
.
auth
}
}
},
},
methods
:
{
methods
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment