UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'S7ybMKNKhoP06n/EktyjhjKIDm8WUsvmq4rHyiVOQRw='
WHERE
key_id = 'a337c647969e2c195874923d4c761274d66795a7d66470dbacbb983a99fa8ec3'
AND (
token = 'S7ybMKNKhoP06n/EktyjhjKIDm8WUsvmq4rHyiVOQRw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)