UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gPTza1aaWy+ylx4LJlMjzdH7cLmKitr7ZNCltQnh1wE='
WHERE
key_id = 'fdb172429b5d4e3e4a87fe74f34b89165be8459ab3322914863a70c996848f48'
AND (
token = 'gPTza1aaWy+ylx4LJlMjzdH7cLmKitr7ZNCltQnh1wE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)