UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'pguc3YLZPa4m5MRlopbh0X/hc8MdceGc2Y3ogkeofY8='
WHERE
key_id = 'c704ea4a2f11998093eecf003397235167a278b12e56343e3cc4e22216a514f6'
AND (
token = 'pguc3YLZPa4m5MRlopbh0X/hc8MdceGc2Y3ogkeofY8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)