UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ySmiNrkNcesuAt2zhpEYbRL15iSv8rTEymIU6A6DPn4='
WHERE
key_id = '2ed7f765c1b02a9384e1e07abdd20a02e3f0b1271ff029d5f64186016d42c7ac'
AND (
token = 'ySmiNrkNcesuAt2zhpEYbRL15iSv8rTEymIU6A6DPn4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)