Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
die_coolen_jungs
our_own_cloud_project
Commits
8d74e28a
Commit
8d74e28a
authored
9 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #20438 from owncloud/memcache-key-length-fix
Handle errors on memcached level
parents
6efa7286
c9b671a1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/memcache/memcached.php
+30
-8
30 additions, 8 deletions
lib/private/memcache/memcached.php
with
30 additions
and
8 deletions
lib/private/memcache/memcached.php
+
30
−
8
View file @
8d74e28a
...
...
@@ -41,9 +41,9 @@ class Memcached extends Cache implements IMemcache {
parent
::
__construct
(
$prefix
);
if
(
is_null
(
self
::
$cache
))
{
self
::
$cache
=
new
\Memcached
();
$servers
=
\OC
_
Config
::
getValue
(
'memcached_servers'
);
$servers
=
\OC
::
$server
->
getSystem
Config
()
->
getValue
(
'memcached_servers'
);
if
(
!
$servers
)
{
$server
=
\OC
_
Config
::
getValue
(
'memcached_server'
);
$server
=
\OC
::
$server
->
getSystem
Config
()
->
getValue
(
'memcached_server'
);
if
(
$server
)
{
$servers
=
array
(
$server
);
}
else
{
...
...
@@ -72,10 +72,12 @@ class Memcached extends Cache implements IMemcache {
public
function
set
(
$key
,
$value
,
$ttl
=
0
)
{
if
(
$ttl
>
0
)
{
re
turn
self
::
$cache
->
set
(
$this
->
getNamespace
()
.
$key
,
$value
,
$ttl
);
$
re
sult
=
self
::
$cache
->
set
(
$this
->
getNamespace
()
.
$key
,
$value
,
$ttl
);
}
else
{
re
turn
self
::
$cache
->
set
(
$this
->
getNamespace
()
.
$key
,
$value
);
$
re
sult
=
self
::
$cache
->
set
(
$this
->
getNamespace
()
.
$key
,
$value
);
}
$this
->
verifyReturnCode
();
return
$result
;
}
public
function
hasKey
(
$key
)
{
...
...
@@ -84,7 +86,9 @@ class Memcached extends Cache implements IMemcache {
}
public
function
remove
(
$key
)
{
return
self
::
$cache
->
delete
(
$this
->
getNamespace
()
.
$key
);
$result
=
self
::
$cache
->
delete
(
$this
->
getNamespace
()
.
$key
);
$this
->
verifyReturnCode
();
return
$result
;
}
public
function
clear
(
$prefix
=
''
)
{
...
...
@@ -121,7 +125,9 @@ class Memcached extends Cache implements IMemcache {
* @return bool
*/
public
function
add
(
$key
,
$value
,
$ttl
=
0
)
{
return
self
::
$cache
->
add
(
$this
->
getPrefix
()
.
$key
,
$value
,
$ttl
);
$result
=
self
::
$cache
->
add
(
$this
->
getPrefix
()
.
$key
,
$value
,
$ttl
);
$this
->
verifyReturnCode
();
return
$result
;
}
/**
...
...
@@ -133,7 +139,9 @@ class Memcached extends Cache implements IMemcache {
*/
public
function
inc
(
$key
,
$step
=
1
)
{
$this
->
add
(
$key
,
0
);
return
self
::
$cache
->
increment
(
$this
->
getPrefix
()
.
$key
,
$step
);
$result
=
self
::
$cache
->
increment
(
$this
->
getPrefix
()
.
$key
,
$step
);
$this
->
verifyReturnCode
();
return
$result
;
}
/**
...
...
@@ -144,10 +152,24 @@ class Memcached extends Cache implements IMemcache {
* @return int | bool
*/
public
function
dec
(
$key
,
$step
=
1
)
{
return
self
::
$cache
->
decrement
(
$this
->
getPrefix
()
.
$key
,
$step
);
$result
=
self
::
$cache
->
decrement
(
$this
->
getPrefix
()
.
$key
,
$step
);
$this
->
verifyReturnCode
();
return
$result
;
}
static
public
function
isAvailable
()
{
return
extension_loaded
(
'memcached'
);
}
/**
* @throws \Exception
*/
private
function
verifyReturnCode
()
{
$code
=
self
::
$cache
->
getResultCode
();
if
(
$code
===
\Memcached
::
RES_SUCCESS
)
{
return
;
}
$message
=
self
::
$cache
->
getResultMessage
();
throw
new
\Exception
(
"Error
$code
interacting with memcached :
$message
"
);
}
}
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