UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'apZ/xVmNDTwFA48nv0p/jffTAD09kx/oOW+K5EgOHVg='
WHERE
key_id = 'dc401ddb085744e22e0d205623fec7a2afde1e4343363ea601a8268c364eaf06'
AND (
token = 'apZ/xVmNDTwFA48nv0p/jffTAD09kx/oOW+K5EgOHVg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)