Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
姜枫
9 years ago
Commit
30c8a677a2ddbd4a83146762d11037f7279be4c1
1 parent
52a604c2
edit shut memcache read
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
6 deletions
library/Api/Yohobuy.php
library/Plugin/Cache.php
yaf/Hood/Cache/Memcached.php
yohobuy/m.yohobuy.com/configs/core/cache.testing.config.ini
library/Api/Yohobuy.php
View file @
30c8a67
...
...
@@ -165,7 +165,7 @@ class Yohobuy
$url
=
self
::
httpBuildQuery
(
$url
,
$data
);
}
//echo $url;
UdpLog
::
debug
(
'get api'
,
$url
);
UdpLog
::
debug
(
'get
shut
api'
,
$url
);
/* 开启缓存的情况 */
if
(
$cache
&&
USE_CACHE
)
{
...
...
@@ -243,6 +243,8 @@ class Yohobuy
if
(
!
empty
(
$userAgent
))
{
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
$userAgent
);
}
UdpLog
::
debug
(
'call api: '
,
$url
);
$result
=
curl_exec
(
$ch
);
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
...
...
@@ -670,8 +672,11 @@ class Yohobuy
return
false
;
}
$interfaceShunt
=
Cache
::
get
(
'INTERFACE_SHUT_KEY'
,
'master'
);
UdpLog
::
debug
(
'read memcache'
);
$interfaceShunt
=
Cache
::
getBy
(
'INTERFACE_SHUT_KEY'
,
'master'
);
UdpLog
::
debug
(
'read memcahe: '
,
$interfaceShunt
);
if
(
empty
(
$interfaceShunt
))
{
return
false
;
}
...
...
@@ -753,4 +758,4 @@ class Yohobuy
return
$url
;
}
}
}
\ No newline at end of file
...
...
library/Plugin/Cache.php
View file @
30c8a67
...
...
@@ -94,6 +94,29 @@ class Cache
}
/**
* 直接查询缓存,不对key做任何处理
*/
public
static
function
getBy
(
$key
,
$node
=
'master'
)
{
$result
=
array
();
try
{
// WINDOWS
if
(
DIRECTORY_SEPARATOR
===
'\\'
)
{
$result
=
HoodCache
::
Memcache
(
$node
)
->
getBy
(
key
));
}
// LINUX
else
{
$result
=
HoodCache
::
Memcached
(
$node
)
->
getBy
(
key
));
}
}
catch
(
Exception
$e
)
{
$result
=
array
();
}
return
$result
;
}
/**
* 清除缓存
*
* @param string $key 键名
...
...
yaf/Hood/Cache/Memcached.php
View file @
30c8a67
...
...
@@ -167,6 +167,11 @@ class Memcached extends Root implements CacheInterface
return
$this
->
init
()
->
get
(
$this
->
_makeTag
()
.
$key
,
$cacheCb
,
$casToken
);
}
public
function
getBy
(
$key
,
$cacheCb
=
null
,
&
$casToken
=
null
)
{
return
$this
->
init
()
->
get
(
$key
,
$cacheCb
,
$casToken
);
}
/**
* 向一个新的key下面增加一个元素
* @param $key
...
...
yohobuy/m.yohobuy.com/configs/core/cache.testing.config.ini
View file @
30c8a67
[memcached]
master.hosts
=
127.0.0.1:11212,127.0.0.1:11213
slave.hosts
=
127.0.0.1:11212,127.0.0.1:11213
session.hosts
=
127.0.0.1:11212,127.0.0.1:11213
master.hosts
=
127.0.0.1:12111
slave.hosts
=
127.0.0.1:12111
session.hosts
=
127.0.0.1:12111
[redis]
servers.hosts
=
127.0.0.1:6379
\ No newline at end of file
...
...
Please
register
or
login
to post a comment