UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'YNuTiMwTxbIElS9sgumhvgaF+DGBW4ycBNWnTve1jls='
WHERE
key_id = '5c83d813c1f792467a470735620ac8aa6ea2e1e8480f1373363760be714deb03'
AND (
token = 'YNuTiMwTxbIElS9sgumhvgaF+DGBW4ycBNWnTve1jls='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)