Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
system
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
_site-res
system
Commits
f6f18f2b
Commit
f6f18f2b
authored
Aug 14, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增自增REDIS方法
parent
37cf5025
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
DefaultBaseImpl.php
classes/fpf/cache/DefaultBaseImpl.php
+4
-0
TableConst.php
classes/fpf/cache/TableConst.php
+6
-0
TraitYiiHashTable.php
classes/fpf/cache/TraitYiiHashTable.php
+10
-0
No files found.
classes/fpf/cache/DefaultBaseImpl.php
View file @
f6f18f2b
<?php
namespace
fpf\cache
;
use
fpf\cache\TableConstant
;
/**
* 简单的KEY VALUE形式的构造真实KEY的方法
*/
...
...
@@ -11,10 +13,12 @@ class DefaultBaseImpl
{
return
$db_name
.
TableConstant
::
CONNECTOR_TAG
.
$table_name
.
TableConstant
::
CONNECTOR_TAG
.
$key
;
}
public
static
function
getHashTable
(
$db_name
,
$table_name
)
{
return
$db_name
.
TableConstant
::
CONNECTOR_TAG
.
$table_name
;
}
public
static
function
checkTable
(
$db_name
,
$table_name
)
{
if
(
!
isset
(
TableConstant
::
$table_list
[
$db_name
.
TableConstant
::
CONNECTOR_TAG
.
$table_name
]))
{
...
...
classes/fpf/cache/TableConst.php
View file @
f6f18f2b
<?php
namespace
fpf\cache
;
/**
...
...
@@ -17,10 +18,13 @@ class TableConstant
const
TABLE_HASH_LATEST_DEAL_USDT
=
'LATEST_DEAL_USDT'
;
const
TABLE_SIMPLE_USD_CNY_RATE
=
'USD_CNY_RATE'
;
const
TABLE_HASH_IP_INTER
=
'IP_INTER'
;
/**
* db name list
*/
const
DB_MARKET_SERVICE
=
'market-service'
;
const
DB_ZHAOBI_API
=
'zhaobi-api'
;
/**
* table check
*/
...
...
@@ -32,5 +36,7 @@ class TableConstant
self
::
DB_MARKET_SERVICE
.
self
::
CONNECTOR_TAG
.
self
::
TABLE_HASH_LATEST_DEAL_USDT
=>
true
,
self
::
DB_MARKET_SERVICE
.
self
::
CONNECTOR_TAG
.
self
::
TABLE_SIMPLE_USD_CNY_RATE
=>
true
,
self
::
DB_ZHAOBI_API
.
self
::
CONNECTOR_TAG
.
self
::
TABLE_HASH_IP_INTER
=>
true
,
];
}
classes/fpf/cache/TraitYiiHashTable.php
View file @
f6f18f2b
<?php
namespace
fpf\cache
;
use
fpf\cache\DefaultBaseImpl
;
...
...
@@ -10,6 +11,7 @@ trait TraitYiiHashTable
{
return
DefaultBaseImpl
::
getHashTable
(
$db_name
,
$table_name
);
}
public
static
function
getByTable
(
$table
)
{
self
::
checkTable
(
self
::
DB_NAME
,
$table
);
...
...
@@ -42,6 +44,14 @@ trait TraitYiiHashTable
return
Yii
::
$app
->
redis
->
hget
(
$table
,
$key
);
}
public
static
function
increaseByTableKey
(
$table
,
$key
,
$step
=
1
)
{
self
::
checkTable
(
self
::
DB_NAME
,
$table
);
$table
=
self
::
getHashTable
(
self
::
DB_NAME
,
$table
);
return
Yii
::
$app
->
redis
->
hincrby
(
$table
,
$key
,
$step
);
}
public
static
function
setByTableKey
(
$table
,
$key
,
$value
)
{
self
::
checkTable
(
self
::
DB_NAME
,
$table
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment