UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'q7COf15SeeWjj4PAAC353Ay5vqWZ5kU7tRSn11JM1Io='
WHERE
key_id = '52adee37354bbd05b9a08ae7054d8ba455b97d8ff7b04a2837c3fd3564a80859'
AND (
token = 'q7COf15SeeWjj4PAAC353Ay5vqWZ5kU7tRSn11JM1Io='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)